admin管理员组文章数量:1024630
I have two projects, both of them using Docker in local environment: frontend is :3000 and backend is (:443)
Backend has an API made with ApiPlatform, Lexik JWT and NelmioCors: everything is working and the /api/authentication returns 200 and sets and http-only cookie in the server.
When frontend tries to access to this endpoint, everything's fine and it receives the header set-cookie with JWTToken=xxxxx
I don't receive any message about cors problem, everything works fine and I get a 200 response in the frontend.
But browser doesn't store the cookie.
If I try the endpoint in the swagger page of ApiPlatform, works fine and the cookie is stored.
In NextJS I have written { withCredentials: true }, and I can see the logs in the backend with the access:
async function login() {
console.log('Login');
const email = process.env.NEXT_PUBLIC_API_EMAIL;
const password = process.env.NEXT_PUBLIC_API_PASSWORD;
await apiClient.post(`${process.env.NEXT_PUBLIC_API_URL}/authentication`, {
email: email,
password: password,
});
}
Here you receive set-cookie header:
apiClient.interceptors.response.use(
function (response) {
console.log('Interceptor for response successful in ' + response.headers["set-cookie"]);
return response;
},........
NextJs access to the endpoint on the url https://container_service_name because I can't use there the domain name.
What am I fetting?
I have two projects, both of them using Docker in local environment: frontend is :3000 and backend is (:443)
Backend has an API made with ApiPlatform, Lexik JWT and NelmioCors: everything is working and the /api/authentication returns 200 and sets and http-only cookie in the server.
When frontend tries to access to this endpoint, everything's fine and it receives the header set-cookie with JWTToken=xxxxx
I don't receive any message about cors problem, everything works fine and I get a 200 response in the frontend.
But browser doesn't store the cookie.
If I try the endpoint in the swagger page of ApiPlatform, works fine and the cookie is stored.
In NextJS I have written { withCredentials: true }, and I can see the logs in the backend with the access:
async function login() {
console.log('Login');
const email = process.env.NEXT_PUBLIC_API_EMAIL;
const password = process.env.NEXT_PUBLIC_API_PASSWORD;
await apiClient.post(`${process.env.NEXT_PUBLIC_API_URL}/authentication`, {
email: email,
password: password,
});
}
Here you receive set-cookie header:
apiClient.interceptors.response.use(
function (response) {
console.log('Interceptor for response successful in ' + response.headers["set-cookie"]);
return response;
},........
NextJs access to the endpoint on the url https://container_service_name because I can't use there the domain name.
What am I fetting?
本文标签:
版权声明:本文标题:javascript - Cookie http-only is not stored on browswer when it's received as a set-cookie header from the backend (Back 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745609427a2158914.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论