diff --git a/routes/_middleware.ts b/routes/_middleware.ts index 58634eb..4095e13 100644 --- a/routes/_middleware.ts +++ b/routes/_middleware.ts @@ -6,10 +6,11 @@ export async function handler(request: Request, ctx: FreshContext) { // Update fresh context state with session ctx.state = { ...ctx.state, session: SessionStore.getFromRequest(request) } - // Allow service worker to serve root scope + // Get response const response = await ctx.next() - const url = new URL(request.url) - if (url.pathname.endsWith('island-startserviceworker.js')) { + + // Allow service worker to serve root scope + if (ctx.url.pathname.endsWith('island-startserviceworker.js')) { response.headers.set('Service-Worker-Allowed', '/') }