-
Notifications
You must be signed in to change notification settings - Fork 1
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
Configure API to work on Vercel from Next SSR #41
Conversation
- Set up axios instance to use correct public Vercel URL for API calls during server-side rendering - Inject user's client-side cookies during API request - Create demo example to illustrate server-side API call with axios and a native POST request from the client - Update Uvicorn `host` to resolve IPv6 issues - Configure Next rewrite which acts like a Vercel rewrite - This allows for local client-side testing of API endpoints and makes the API paths publicly accessible at `/api/`
Deploy preview for irvinehacks-site-2024 ready!
|
Deploy preview for irvinehacks-site-2024-sanity ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waalbert was dealing with an Axios error related to IPv6 though (ECONNREFUSED ::1:8000) until he removed the ::1
entry from /etc/hosts
. I'm pretty sure this isn't the proper way to resolve the error, but you did already change the Uvicorn host to localhost
so I'm not too sure what the issue is here. To make matters even more peculiar, I'm not able to replicate the same error on my machine, perhaps due to an operating system/networking difference.
Interesting, on my machine, Node v16 resolves localhost to IPv4 whereas Node v17, v18, and v19 resolve IPv6 first, but interestingly Node v20 resolves IPv4 first. None of the versions seem to respect the order of the hosts file. |
Ok that makes more sense. Currently, I'm on Node 20. |
Changes
host
to resolve IPv6 issues/api/
Testing
Clone the branch locally and visit
/demo
while also having the local API server running with Uvicornusername
Visit
/demo
in the deployed preview