Skip to content

Commit

Permalink
fix(nitro): handle static assets and api routes for service-worker
Browse files Browse the repository at this point in the history
…preset (#518)
  • Loading branch information
farnabaz authored Sep 9, 2021
1 parent 69fd546 commit 9808f05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime/entries/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import '#polyfill'
import { localCall } from '../server'

const STATIC_ASSETS_BASE = process.env.NUXT_STATIC_BASE + '/' + process.env.NUXT_STATIC_VERSION

addEventListener('fetch', (event: any) => {
const url = new URL(event.request.url)

if (url.pathname.includes('.') /* is file */) {
if (url.pathname.includes('.') && !url.pathname.startsWith(STATIC_ASSETS_BASE) && !url.pathname.startsWith('/api')) {
return
}

Expand Down

0 comments on commit 9808f05

Please sign in to comment.