Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rootURL #53

Closed
thorsteinsson opened this issue May 3, 2016 · 8 comments
Closed

Add support for rootURL #53

thorsteinsson opened this issue May 3, 2016 · 8 comments
Labels

Comments

@thorsteinsson
Copy link
Contributor

When using rootURL on the router, FastBoot completely ignores it and runs the app with the default rootURL /.

const Router = Ember.Router.extend({
  rootURL: '/en/'
});

Here's a repo to test it: https://github.com/thorsteinsson/ember-fastboot-rooturl

@esistgut
Copy link

esistgut commented May 5, 2016

I have the same issue for the same use case, FastBoot is ignoring my

  let router = appInstance.lookup('router:main');
  router.rootURL = `/${language}/`;

inside an instance initializer.

@fivetanley
Copy link

Is this also generated in links, or are you just expecting a redirect when you visit /?

@esistgut
Copy link

esistgut commented May 5, 2016

Changing the rootURL makes all the links change as well. I'm doing this to "mount" my routes to the correct language prefix and to have different URLs for different languages.

@jasonmit
Copy link
Contributor

jasonmit commented May 7, 2016

I actually think this is a bug in the visit API since fastboot is providing it all the information it needs (the full path).

are you just expecting a redirect when you visit /?

I wouldn't expect it to redirect, but to assert like the router currently does when the requested URL doesn't start with the specified rootURL.

Is this also generated in links

It doesn't.

curl http://localhost:3000/en/

<!-- trimmed the output -->
<a id="ember995" href="/test" class="ember-view">test</a>

client-side http://localhost:4200/en/

<!-- trimmed the output -->
<a id="ember385" href="/en/test" class="ember-view">test</a>

Did some investigating, I believe this to be an issue with the visit API using the none routing location. Which would explain why it's not respecting rootURL, when generating links.

So I believe this is two bugs:

  • rootURL isn't respected when the visit API handles the url
  • location is set to none in fastboot land which doesn't respect rootURL when used to generate urls (link-tos)

@sebastianseilund
Copy link

I can confirm that FastBoot doesn't work when rootURL is set. The two issues described by @jasonmit are the causes:

  • rootURL isn't respected when the visit API handles the url
  • location is set to none in fastboot land which doesn't respect rootURL when used to generate urls (link-tos)

I got it working (using extreme monkey patching) by adding the code from this Gist into app/instance-initializers/fastboot-fix.js.

@tomdale
Copy link
Contributor

tomdale commented May 16, 2016

Sounds like a bug in the NoneLocation; let's fix it in Ember itself.

@tomdale tomdale added the bug label May 16, 2016
@sebastianseilund
Copy link

I think you can close this one and track the issue in emberjs/ember.js#13464.

@tomdale tomdale closed this as completed May 17, 2016
@jasonmit
Copy link
Contributor

I released a tiny addon to unblock, ember install ember-fastboot-rooturl-patch while we wait for the fix to land in stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants