ember-cli-fastboot icon indicating copy to clipboard operation
ember-cli-fastboot copied to clipboard

Fastboot doesn't run with http://localhost:4200/?fastboot=true, but does on CURL

Open omairvaiyani opened this issue 7 years ago • 5 comments

We have just begun to add fastboot to our project, and have run into this issue.

Starting the server with ember serve does not seem to use fastboot by default when I visit localhost:4200?fastboot=true from the browser. It does however run with this command in terminal curl 'http://localhost:4200/' -H 'Accept: text/html'.

The ember-cli terminal only prints App is being served by FastBoot when I make the request via CURL, but not if I visit via the browser. Could this have anything to do with our use of a service worker?

omairvaiyani avatar Feb 09 '18 11:02 omairvaiyani

Could this have anything to do with our use of a service worker?

Absolutely! I would recommend disabling SW while developing.

simonihmig avatar Feb 09 '18 15:02 simonihmig

Thanks @simonihmig that was the culprit!

Just as an aside, will the use of service workers have any bearing in the production environment?

omairvaiyani avatar Feb 10 '18 13:02 omairvaiyani

@simonihmig I would also like to know if there is any interaction between fastboot and ember-service-worker in production?

scottkidder avatar Oct 25 '18 21:10 scottkidder

Yes, depending on your SW's implementation, a user might hit your FastBoot server only for the first ever visit. After that any following visit would not load the HTML page from the server, but rather use the index.html cached by your SW. At least that's how ember-service-worker-index would behave.

simonihmig avatar Oct 26 '18 08:10 simonihmig

I see, that makes sense. Maybe it should be documented in ember-service-worker-index? Maybe a better setup for sw + fastboot would involve allowing ember-service-worker-cache-fallback to serve index.html only when network is unavailable?

scottkidder avatar Oct 26 '18 13:10 scottkidder