-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: github codespace setup #2598
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/CWsBmDp38JbwjMz6H4BVp51BhMa8 |
Codecov Report
@@ Coverage Diff @@
## main #2598 +/- ##
=====================================
Coverage 9.90% 9.90%
=====================================
Files 84 84
Lines 1404 1404
Branches 396 396
=====================================
Hits 139 139
Misses 1039 1039
Partials 226 226 Continue to review full report at Codecov.
|
Interesting! After #2552 lands though, the dev app set up might change drastically. I am hoping that vercel/next.js#22867 will simplify things. Also, could the |
@balazsorban44 unfortunately the We obviously don't need to go forward with this, but I was experimenting with the devcontainers / codespaces for work and thought it'd be a nice addition here for you and others to easily spin up env's out of PR's, check things out, etc. |
I am not against it, happy to discuss it! |
OMG ! You did this magic 🌟 🥇
Yes indeed and actually even if experimental I feel it's safe to go for it in the next-auth examples. I converted a repo lately without problem. For NextJS 11.1+, simply enable experimental flagconst nextConfig = {
experimental: {
externalDir: true,
},
};
export default nextConfig; If there's ome risk to enable experimental, this one works with all next versions since NextJs 10 For NextJS < 11, simply add a webpack overrideconst nextConfig = {
webpack: (config, { defaultLoaders }) => {
// Will allow transpilation of shared packages through tsonfig paths
// @link https://github.com/vercel/next.js/pull/13542
const resolvedBaseUrl = path.resolve(config.context, "../../");
config.module.rules = [
...config.module.rules,
{
test: /\.(tsx|ts|js|jsx|json)$/,
include: [resolvedBaseUrl],
use: defaultLoaders.babel,
exclude: (excludePath) => {
return /node_modules/.test(excludePath);
},
},
];
return config;
},
};
I think so too, but maybe not a bad idea... Are you trying to get multiple apps / example running ?
Edit: Ah yes this is a little more complex... I'm interested how to find it too. In sandboxes (vercel, netlify), I can use an environment variable for the final url. Don't know about devcontainers though ? Is it possible to get origin it from request rather than env ? (only in dev) |
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Interesting! I use devcontainers myself locally based on the "Docker-from-Docker" configuration. If meant to be for development-level activities, I have some suggestions that may be helpful, and some general questions since I'm new to NodeJS development:
|
@kriswuollett hey thanks for the all the feedback! So this was just an experimental thing, definitely not 100% thought through yet, at least on my part haha. But I can hopefully answer some of your questions. We're not running it in a 'docker-in-docker' type setup, so it clones the repo and runs the container containing node from Github codespaces currently is free (See blue note box here: https://docs.github.com/en/codespaces/codespaces-reference/understanding-billing-for-codespaces - "Note: Codespaces is free to use for all organizations on a GitHub Team.."). However after reading your message and looking into it, it looks like the initial free period is expiring Sept. 10th, so in just about a week :( Regarding dynamic providers.. I was talking to Balazs recently about how best we could include some OAuth configs here for testing, without leaking or potentialy exposing our internal testing OAuth keys. Maybe if we conditionally add the configs to import NextAuth from "next-auth"
const nextAuthConfig = {
providers: [],
..
}
process.env.GITHUB_SECRET && nextAuthConfig.providers.push(GithubProvider({
..
}))
export default NextAuth(nextAuthConfig) We could allow users to add their own OAuth keys, and it would automatically add / enable that provider if the appropriate provider key / secret is available. Is that kind of what you were picturing? I think thats apretty good way of avoiding having to insert our own keys and potentially losing them, and making it easy for the users / contirbutors to setup and use theirs. I'm not familiar with Keycloak, but bundling another Auth provider in there to test could be another option, instead of the oauth configs. I'm open to whatever makes it easy for users / contirbutors to get up to speed 👍 |
@ndom91, cool. It sounds like all of the Yes, your example with As far as the Let me know if you need any help testing. For test the app, bundling something like Keycloak in a devcontainer came first to mind, just because I'm currently working with it, and may implement #2637. But perhaps a better option would be something nodejs native like |
I don't have strong opinions on this, it looks like there is interest (at least from you @kriswuollett :D ) to develop I don't really see the point of a conditional inclusion of providers. If you don't add the secrets, the given provider simply won't work. The only thing important to me here is that we are clear that these environments have a public URL, so you should NEVER use an active/prod provider. Other than that, I am probably fine with anything. |
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks! |
Hi there! It looks like this issue hasn't had any activity for a while. To keep things tidy, I am going to close this issue for now. If you think your issue is still relevant, just leave a comment and I will reopen it. (Read more at #912) Thanks! |
Reasoning 💡
This would make it super easy to checkout any PR, issue, etc. in a preconfigured dev env in the browser in the comfortable VS Code interface!
So I added a
.devcontainer
setup for enabling people to spin up a dev environment with codespaces in no time. Next to where you can set secrets for github actions, you can also set env vars for codespaces. There I set the auth0 id / secret / domain for testing.What works so far is spinning up the node container, installing the
next-auth
dependencies, as well as the/app
dependencies and starting the dev server. You can then visit the example app homepage via the generated preview URL 🎉Things that still do not work:
copy:css
for some reason doesn't ocpydist/css/index.css
to where it should be, althoughcopy:app
does work 🤷NEXTAUTH_URL
Whenever you start a codespace, any ports you forward from the container get a dynamic preview URL like this:
You can set env vars in the
.devcontainer.json
file in a few ways - but I'm not sure how we'd get that dynamic URL ahead of time, or if there is any programmatic way to get it..You can open up any PR (like this one 😉) in a codespace here:
Checklist 🧢
Affected issues 🎟