lukeed / sirv

An optimized middleware & CLI application for serving static files~!
MIT License
1.07k stars 58 forks source link

Can't get ignores option to work with polka #77

Closed eritbh closed 4 years ago

eritbh commented 4 years ago

Trying to use sirv and polka to serve a Vue SPA backed by an API. My server code looks like this:

const app = polka();
app.use(sirv('./dist', {
  dev: true,
  single: true,
  ignores: ['/api'],
}));
app.use('/api', /* another polka app */);

No matter what I try, I can't get sirv to stop responding to requests on /api and let the API app handle them. Commenting out the single: true line lets me hit my API routes correctly, which leads me to believe it's a sirv issue?

Any help would be appreciated.

eritbh commented 4 years ago

Seems like this is actually an issue in polka@latest. sirv wasn't being shown the full URL, just the URL relative to the sub-app on /api, which meant it never actually saw the /api in the path and didn't think it should be ignored.

Upgrading to polka@next (the 1.0 line) fixed the issue for me, so I'll close this.