Skip to content
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

Use runtime environment values on client #849

Open
lukevella opened this issue Sep 12, 2023 · 12 comments
Open

Use runtime environment values on client #849

lukevella opened this issue Sep 12, 2023 · 12 comments

Comments

@lukevella
Copy link
Owner

When we build the docker image for Rallly, values like NEXT_PUBLIC_BASE_URL are set during build time for client side code and do not match what is expected during runtime. We can use next-runtime-env to get the runtime value of these environment variables.

@lukevella lukevella changed the title Use next-runtime-env to access config values on client Use runtime environment values on client Sep 12, 2023
@nebulade
Copy link

Came here to report that the app kept redirecting to localhost:3000 and this is probably the reason then. The Cloudron package is built without a final domain, as it is not known yet. Guess we have to wait for a package update then for this to be added.

@lukevella
Copy link
Owner Author

@nebulade, is this a new issue in 3.2.0?

@nebulade
Copy link

hm I see this issue is much older. Well it was detected by our tests, so I started investigation. Maybe then it is related to 703d551 ?

@lukevella
Copy link
Owner Author

I don't think it's likely to be that. Do you know what the last working version was?

@nebulade
Copy link

Last working version was 3.1.0 so possibly then I am chasing the wrong thing. I see that the process.env. usage was always like that so always during the build?

@nebulade
Copy link

Maybe should split this into a new issue then. Also we had to apply the same fix exporting HOSTNAME as we had to for baptisteArno/typebot.io#911 (comment) possibly then some nextjs update making the difference

@lukevella
Copy link
Owner Author

I suspect there is some way to fix this but I'd need some steps to be able to reproduce it. Are you able to provide that?

@nebulade
Copy link

Tried to get the app working locally to reproduce the issue, but didn't succeed to get it working at all there. So I went to bisect it via a Cloudron build package. For reference its build like this: https://git.cloudron.io/cloudron/rallly-app/-/blob/main/Dockerfile?ref_type=heads The env variables we set during runtime (so after the build) are https://git.cloudron.io/cloudron/rallly-app/-/blob/main/start.sh?ref_type=heads#L26 and that worked before.

So the commit causing the issue after bisecting is 6fa66da which causes a redirect to http://localhost:3000 after initial loading. Will see if I can drill down further to this issue, but any help is much appreciated.

@lukevella
Copy link
Owner Author

lukevella commented Oct 31, 2023

Ah right that makes sense. You will need to set NEXTAUTH_URL as well to the same value as NEXT_PUBLIC_BASE_URL. Annoyingly this env var is required by next-auth. I didn't want to expose this since it is an implementation detail so it is handled in the start script here: https://github.com/lukevella/rallly/blob/main/scripts/docker-start.sh#L4

@lukevella
Copy link
Owner Author

I'll try to change how this is handled so that it doesn't require you to add NEXTAUTH_URL as well though but for now that could be a quick fix.

@nebulade
Copy link

Ah right, should have seen that start script change earlier. Have triggered a new test run with it now, so if that works its fine, no need to change this in the code then.

@nebulade
Copy link

I can confirm it works with NEXTAUTH_URL also set now. Thanks a lot for your help and sorry for highjacking this, now unrelated issue :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants