proxy cookies
See original GitHub issueWhat problem does this feature solve?
Handle cookie jar in order to automatically resend received cookies on every subsequent request (server-side). Actually, axios doesn’t resend cookie received (with set-cookie) by nuxt serverResponse (in a serverMiddleware for example). It cause many problem in my nuxt app.
I have to do something like this (temporary fix) :
$axios.onResponse((resp) => {
if(resp.headers['set-cookie'] && process.server){
try{
// add header to nuxt's server response
res.setHeader('Set-Cookie', [ ...resp.headers['set-cookie'] ])
}catch(e) {}
}
return resp
})
but in some case, set-cookie header is duplicated…
<div align="right">This feature request is available on Nuxt community (#c329)</div>Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:28 (6 by maintainers)
Top Results From Across the Web
Cookies Overview and HTTP Proxies - Computer Science
What is a Cookie? ▫ Small piece of data generated by a web server, stored on the client's hard drive. ▫ Serves as...
Read more >How to Allow Cookies on a Proxy - Small Business - Chron.com
1. Open one of the cookie-optional proxy Web applications in a Web browser (see Resources). · 2. Type the URL to your blocked...
Read more >Cookie Proxies
Cookie Proxies Sells High Quality Residential Proxies & The Fastest Data Center Proxies. Multiple Data Center Locations Such As Ashburn, Chicago, ...
Read more >Cookie? Proxy? Cache? #1 - Yuta Fujii - Medium
Even if you are not familiar with IT, most of you have ever heard about cookie, proxy, cache. For example: “Remove cookies and...
Read more >Is it permissible for an intermediate proxy to add cookies ...
RFC 2965 HTTP State Management Mechanism, 3.5 Caching Proxy Role it says: Proxies MUST NOT introduce Set-Cookie2 (Cookie) headers of their own ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right, ignore that.
I think I managed to get a working plugin that updates cookies for Axios, and merges them on the response object. This allows sequential requests to have the correct cookies.
And then register it in
nuxt.config.js
I’m currently dealing with the same problem. My backend adds a Set-Cookie header to the response with a new access_token whenever it has expired. This causes issues with SSR because they aren’t forwarded to the client.
I’ve been working around this issue so far by making requests that require authentication from the client, but this takes away the smoothness of SSR.
An issue with the solution provided above is that on subsequent requests Axios might also need to access the new cookies. The ideal solution would be to mimic the behavior of browsers when dealing with cookies.
A possible solution I’ve been considering is to have a server-side plugin that updates the Axios cookies, and the Set-Cookie header on the response, whenever a Set-Cookie header is received.
One possible issue with this solution is that it would proxy all cookies. So a potential filter could be added to not proxy cookies such as
x-powered-by
,x-ratelimit-limit
,x-ratelimit-remaining
, and others.It would be nice to have this as an option, so SSR can be used to the fullest, without worrying about cookies not syncing.