Relative Content

Tag Archive for reactjsnode.jsexpress

I am unable to set the cookies received from the response

I am running a localhost React App on port 3000 and a Express server on port 4000. When I run the request from Postman, the cookies are being set and for any request made after that the cookie is being attached to the headers. But in React, I am getting response cookie but when I send another request, the cookie that was received is not being attached to the header. Please help me how to do it.

API not working when serving static file from express server

I am working on my chat application project which is working fine in development.But when I am serving static file from server chat API is not working which fetch the chat list.It’s responding with a html template.Which is the html template from the dist folder.But the auth APIs at beginning are working in production build.Here is the folder structure-
.
└── Chat app/
├── Client
├── Server
├── .gitignore
├── Readme.md
├── package.lock.json
└── package.json

React, Node.js, jwt Login process. I can’t stay the state with accessToken

I’m using accessToken and refreshToken to login process. I made up my mind to store accessToken in React useState and refreshToken in Cookie by using httpOnly. accessToken is saved in state. refreshToken is saved Cookie. As I login page i can acces next page but when I press F5, I go back to login page. It’s doing well to get accessToken but I have no idea why the website force me to go to login site. Here’s my code