最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - Issue with Axios and Cookies in React and Express Setup - Stack Overflow

programmeradmin3浏览0评论

I’m working on a React frontend with Axios for API requests, and an Express backend with CORS and cookie-parser. My goal is to manage authentication using refresh tokens and access tokens. On login, the refresh token is sent as an HTTP-only cookie, which works fine in Postman, but when sending the same request through Axios, I’m encountering an issue. After the access token expires, I’m sending a request to the /refresh-token endpoint. However, despite setting withCredentials: true in Axios and configuring CORS with origin: true and credentials: true in the backend, req.cookies is still null. The frontend and backend are running on the same host but different ports. Has anyone encountered this problem? Any tips or advice on how to fix this?

LLMs keep asking me to recheck things which are already correct

I tried by setting same site as strict none and lax too, but as said it works fine with postman but not the react app

发布评论

评论列表(0)

  1. 暂无评论