ember-fastboot / ember-cli-fastboot

Server-side rendering for Ember.js apps
http://ember-fastboot.com/
MIT License
851 stars 160 forks source link

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

Open omairvaiyani opened 6 years ago

omairvaiyani commented 6 years ago

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?

simonihmig commented 6 years ago

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

Absolutely! I would recommend disabling SW while developing.

omairvaiyani commented 6 years ago

Thanks @simonihmig that was the culprit!

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

scottkidder commented 5 years ago

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

simonihmig commented 5 years ago

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.

scottkidder commented 5 years ago

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?