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

Don't use / as webUrl, prefer NEXT_PUBLIC_WEB_URL or VERCEL_URL #2104

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

humphd
Copy link
Contributor

@humphd humphd commented Apr 9, 2021

Fixes #2102

I thought I could use / as a fallback URL, but i can't. This fix might also not work, but I want to test it on Vercel.

@humphd
Copy link
Contributor Author

humphd commented Apr 9, 2021

OK, I got this working. I had to update the env variables manually in Vercel to expose the VERCEL_URL to our build script, and expose it as WEB_URL. I also had to add some extra code to prepend https:// to it if it's missing.

While I was doing this, I noticed that we had our vercel.json in the wrong dir, so I moved that too.

PedroFonsecaDEV
PedroFonsecaDEV previously approved these changes Apr 9, 2021
@humphd
Copy link
Contributor Author

humphd commented Apr 9, 2021

I did one more fix to simplify the code in the front-end, and move the https:// prefix logic to the build.

Locally this gives:

Trying to load missing ENV variables from /Users/humphd/repos/telescope/.env
Trying to load missing ENV variables from /Users/humphd/repos/telescope/config/env.development
Using NEXT_PUBLIC_WEB_URL=https://http://localhost:8000
Using NEXT_PUBLIC_API_URL=http://localhost:3000
Using NEXT_PUBLIC_IMAGE_URL=http://localhost/v1/image
Using NEXT_PUBLIC_POSTS_URL=http://localhost/v1/posts
Using NEXT_PUBLIC_AUTH_URL=http://localhost/v1/auth

And on Vercel:

11:05:09.639 | Trying to load missing ENV variables from /.env
11:05:09.639 | Trying to load missing ENV variables from /config/env.development
11:05:09.639 | Using NEXT_PUBLIC_WEB_URL=https://telescope-p5vfj150a-humphd.vercel.app
11:05:09.639 | Using NEXT_PUBLIC_API_URL=https://dev.telescope.cdot.systems
11:05:09.639 | Using NEXT_PUBLIC_IMAGE_URL=https://dev.api.telescope.cdot.systems/v1/image
11:05:09.639 | Using NEXT_PUBLIC_POSTS_URL=https://dev.api.telescope.cdot.systems/v1/posts
11:05:09.640 | Using NEXT_PUBLIC_AUTH_URL=https://dev.api.cdot.systems/v1/auth

Everything looks good.

@humphd humphd merged commit a88e462 into Seneca-CDOT:master Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: autodeployment Anything related to auto deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vercel Builds breaking with invalid URL /
3 participants