-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
vite can not get cookie from set-cookie #18025
Comments
This is expected. You are proxying all paths so the request doesn't hit Vite's internal middlewares.
This is also expected. It's a prefix match.
AFAIK Vite doesn't change |
1.The write way of problem1 is works in vue-Cli. |
Vite does not aim for one-to-one compatibility with Vue CLI. This behavior has been existed for a long time and IMHO not worth making a breaking change unless there's many advantages.
It is common to proxy all paths under a specific path and most of the case that way works with people that want to proxy a single path.
I don't get what you mean. |
This method I tried, but it doesn't work for me, because the set-cookie of response don't set path. |
I can't see eye to eye with you to this design. if I set proxy '/a', it works on ‘/a/login’, it is OK.However it can also works on '/api/login'.It is not reasonable. |
Describe the bug
When I send /api/login request to server, it sends me Set-cookie, but I can get cookie in browser.I tried change proxy '/api' to '/', it is useful in vue-cli, however it doesn't send to server any more rather than visit local static resources.
Reproduction
https://gitee.com/kooji/vue3-demo
Steps to reproduce
set proxy
'/': {
target: env.VITE_BASE_URL,
secure: false,
headers: {
Connection: 'keep-alive',
},
changeOrigin: true,
rewrite: (path: string) => path.replace(/^/api/, ''),
},
can not send request and get local static resources.
2.problem 2
set proxy
'/a': {
target: env.VITE_BASE_URL,
secure: false,
headers: {
Connection: 'keep-alive',
},
changeOrigin: true,
rewrite: (path: string) => path.replace(/^/api/, ''),
},
or
'/ap': {
target: env.VITE_BASE_URL,
secure: false,
headers: {
Connection: 'keep-alive',
},
changeOrigin: true,
rewrite: (path: string) => path.replace(/^/api/, ''),
},
When i send /api/login it should not send successfully but it did.
3.problem 3
I have to set proxy as
'/api': {
target: env.VITE_BASE_URL,
secure: false,
headers: {
Connection: 'keep-alive',
},
changeOrigin: true,
rewrite: (path: string) => path.replace(/^/api/, ''),
},
It works, but it cannot get Set-cookie from server.Because cookie path has been setted as '/api'.
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: