WebSocket handshake cookies cloudfront deployment

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


WebSocket handshake cookies cloudfront deployment



I have an angular 6 app & python(django 2.0.6) back-end.
Angular 6 app is deployed using AWS S3 & CloudFront.



Angular 6 app use websocket functionality.
Everything works well locally, but when deployed Angular 6 app fails to pass a cookies with websocket handshake request. (Authorization is by cookies only for websoket connection. There are reasons for that, not relevant.)



Websocket server located at subdomain: `api.site.com``



i tried multiple ways to set cookies in angular 6 app, such as:


let domain = 'api.site.com'

document.cookie = `Token=${token}; domain=${domain}; path=/`;
document.cookie = `Token=${token}; path=/`;
document.cookie = `Token=${token};
document.cookie = `Token=${token}, domain=${domain}, path=/`;



using ngx-cookie-service:


ngx-cookie-service


this.cookieService.set('Token', token, undefined, '/', 'api.site.com');
this.cookieService.set('Token', token, undefined, '/');
this.cookieService.set('Token', token);



token is a JWT token.


token



For all the cases above, Token cookie does not passed with the websocket handshake when the app is deployed. using wss protocol.
angular 6 app runs under the domain site.com (=> api is a subdomain )


Token


wss


site.com


api



Cloudfront behavior is set to pass all cookies.



Please advice what can be a possible reason.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty