You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have it so that a fetch('/api/foo') in the client becomes a rewrite to http://localhost:8000/api/v1/foo in the dev server. It looks something like this:
// next.config.jsmodule.exports=(phase,{ defaultConfig })=>{if(phase===PHASE_DEVELOPMENT_SERVER){return{/* development only config options here */asyncrewrites(){return[{source: "/api/:path*",destination: "http://localhost:8000/api/:path*",},];},};}return{/* config options for all phases except development here */};};
The problem is that if that server contains a Set-Cookie header, that is dropped when it gets to the client.
Describe the solution you'd like
Basically, that rewrites works like a proxy. Ideally, respecting all the headers and stuff.
Perhaps even more ideally, more configuration (and documentation) keys that you can add to each entry in the rewrites. Right now, there's only source, destination, and has. Would be nice to add something like:
What the heck! It is working. Sigh. I tested it with both the browser and curl and it was clear.
But I think what might have happened is that I didn't restart the npm run dev. I'm not sure. Now things are working as expected. Weird.
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.
vercel
locked as resolved and limited conversation to collaborators
Jan 27, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the feature you'd like to request
I have it so that a
fetch('/api/foo')
in the client becomes a rewrite tohttp://localhost:8000/api/v1/foo
in the dev server. It looks something like this:The problem is that if that server contains a
Set-Cookie
header, that is dropped when it gets to the client.Describe the solution you'd like
Basically, that rewrites works like a proxy. Ideally, respecting all the headers and stuff.
Perhaps even more ideally, more configuration (and documentation) keys that you can add to each entry in the
rewrites
. Right now, there's onlysource
,destination
, andhas
. Would be nice to add something like:Describe alternatives you've considered
https://www.npmjs.com/package/next-http-proxy-middleware
The text was updated successfully, but these errors were encountered: