pearofducks / rollup-plugin-dev

development server for rollup with additional logging and options

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

404s from backend proxy shouldn't fallback to spa

abdatta opened this issue · comments

The title says it all!
When we get a 404 response from a proxied backend, it should not fall back to index.html even when spa: true.

A backend server often returns a 404 response when it fails to find some resource. This response is often used by an SPA frontend to show the info in a nice format. We don't want such a request to fallback to an HTML file (with 200 response).

It'll be very helpful if you can either make it the default behaviour to not to fallback from proxied responses, or maybe add a new flag that can turn on this ability.

Thank you for this very helpful plugin!

This sounds like your accepts header isn't set properly. The SPA middleware checks for accepts of html, and only will send a response when that's true.

If you set your accepts header to JSON (application/json), this shouldn't happen.