- From: Jakub T. Jankiewicz <notifications@github.com>
- Date: Thu, 16 May 2024 06:10:14 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 16 May 2024 13:10:18 UTC
@jakearchibald why Service Worker can't create cookies? Header `Set-Cookie` created from service worker is ignored. What is the reason behind this? I want to create an API in service worker using [Wayne library](https://github.com/jcubic/wayne), and I can't do this properly with JWT refresh and access tokens because cookies are not supported in Service Worker. Example code: ```javascript self.addEventListner('fetch', (event) => { const url = new URL(event.request.url); if (url.pathname === '/api/login') { const headers = { "Set-Cookie": "TestCookie=foo; path=/; Max-Age=60;" "TestHeader": "foo" }; cosnt res = new Response('Hello!', { headers }); event.respondWith(new Response('Hello!', { headers })); } }); ``` The `Set-Cookie` header is removed by the browser, the TestHeader is present. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/837#issuecomment-2115207334 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/issues/837/2115207334@github.com>
Received on Thursday, 16 May 2024 13:10:18 UTC