ember-fastboot / ember-cli-fastboot

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

root redirect doesnt work #349

Open izelnakri opened 7 years ago

izelnakri commented 7 years ago
// in app/routes/index.js:
import Ember from 'ember';

const { Route } = Ember;

export default Route.extend({
  redirect() {
      this.transitionTo('public.contact');
  }
});

This does redirect when the app boots on clients browser, however fastboot doesnt redirect this.

kratiahuja commented 7 years ago

Can you provide a reproduction?

BlueRaja commented 6 years ago

We are seeing the same thing in Fastboot RC7 (unfortunately we can't update to 1.1 yet but this doesn't appear to be one of the bugs fixed since then)

Our exact code looks like

app/pods/application/route.js:

beforeModel(transition) {
  if (_.isString(transition.queryParams.resolve)) {
    this.replaceWith('resolve', transition.queryParams.resolve, {
      queryParams: _.omit(transition.queryParams, 'resolve'),
    });
  }
  // Other code
}

The application route's HTML is returned by FastBoot (with an HTTP 200), and is shown until Ember fully loads on the client, at which point the redirection to /resolve happens. The redirection is supposed to happen via the FastBoot response instead (with an HTTP 30x)

BlueRaja commented 6 years ago

By the way, here is how the /resolve route is defined

Router.map(function () { // eslint-disable-line array-callback-return
  this.route('locale-root', { path: '/:locale' }, function () {
    this.route('resolve', { path: '/resolve/:resolve_id', resetNamespace: true });
    ...
  });
});

Also pinging @rwjblue and @stefanpenner since they seem to be the other maintainers not on this thread

kratiahuja commented 6 years ago

@BlueRaja can you please provide a minimal reproduction if possible?

rwjblue commented 6 years ago

Agreed, a repro would be super helpful here....

toddjordan commented 6 years ago

@kratiahuja @rwjblue A not-so-minimal reproduction is the api docs app...

Where something like https://ember-api-docs.herokuapp.com/api/ember/2.18/classes/Engine gives a fastboot rendered page, while going just to https://ember-api-docs.herokuapp.com transitions to the first module, but does it client side, and the document returned from fastboot has no server-rendered content (only the base javascript/style imports to allow things to happen client side like a regular ember app)

(using the heroku url instead of emberjs.com to remove any proxying and fastly caching from the equation)

toddjordan commented 6 years ago

ok, now that it looks like we fixed https://github.com/ember-learn/ember-api-docs/issues/427 That makes this issue our biggest hinderance for SEO in api docs, because the link to API on the emberjs.com website goes to https://emberjs.com/api , which does a route transition to a landing page.

Now eventually we want to add a landing page to /api that describes the overal api docs app, so this may be a moot point when that happens but until then we are hampering seo by returning a blank page from fastboot here (when js takes over on the browser it does the appropriate redirect)