I have a middle wear in my Express app that sets a cookie in the clients browser:
res.cookie('token', '123');
Everything works perfect on a local environment with the front end calling local the server:
axios
.post(`http://localhost:3000/createSomething`, { 'field': "value"})
.then(res => {
console.log('res', res)
})
.catch(err => {
return Promise.reject(
new Error('There is an issue with the /createSomething endpoint')
);
});
In this situation the cookie gets set and I can see it in my dev tools under the Cookies section. The issue is when I change my front end call to point to the AWS Elastic Beanstalk environment:
http://localhost:3000/createSomething -> https://testEnvironment.com/createSomething
The call is successful but no cookie is created in the clients browser. Although, In the response headers I do see:
set-cookie: paigetoken=123; Path=/
A few further details:
- There is a yellow warning symbol at the end of the set-cookie.
- Using CORS
- There is an application load balancer in the AWS environment that handles https. Could this be a factor?
How can I resolve this issue and have my Express app in AWS ELB environment successfully set a cookie in the clients browser? Any insight would be greatly appreciated!