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
API route examples are bad/incorrect #9047
Comments
|
To me it feels a bit unsafe to have your backend make requests to urls defined in headers. Wouldn't it be possible to spoof the host header? |
|
Just bumped into this as well!
It seems that using the header is the way to go indeed. https://zeit.co/docs/v2/advanced/platform/changes-in-now-2-0/#environment-variables
It should be safe https://github.com/zeit/now-builders/issues/55#issuecomment-446422255
|
It may be safe in ZEIT now specifically, but API routes are not restricted to this environment alone. People may copy this example and run it on their own infrastructure. Besides that, it would give the general impression that it's ok to treat the host header as "safe" input. |
Good point indeed 👍 I was caught up with the issue being about Now 2.0 deployments, I guess in other environments the case will always be different and out of scope of this issue? |
|
I'm also running into this. The provided examples do not work when developing locally, due to SSR pages not being able to make requests to the api endpoints. I get 404 errors. |
|
Hi, I think I'm having a similar issue.
I've done I thought maybe the "API resolved without returning data may result in stalled requests" was causing the issue, so I re-wrote my middleware but even after resolving that issue, I'm still getting 502 bad gateway when deploying. |
|
Hi, I didn't whitelist any other domains except my own personal IP address. This is why everything worked locally, but not when I pushed it up to Vercel's servers and my custom domain. In case anyone stumbles upon this comment and is trying to figure out why they're able to hit their DB (mongoDB atlas in the cloud) locally ... but not when you deploy ... make sure you whitelist other IPs than just your own. |
|
Closing as |
|
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Examples bug report
Example name
Describe the bug
All the examples use
getInitialPropsto request from localhost:3000 - which, when you've deployed to now (as per the readme) it blows up and throws a 500 (I just ran a test deploy and it does indeed break).This issue isn't specific to Next.js but it is specific to the examples which suggest releasing.
To Reproduce
Expected behavior
A solution should be offered to handle fetching "self", or the suggestion of deploying to Zeit's now should be removed.
Additional context
Possible workaround that I'm currently using, but feels brittle:
The text was updated successfully, but these errors were encountered: