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

Router's rootURL isn't working in 1.12 beta #10943

Closed
tcjr opened this issue Apr 23, 2015 · 35 comments · Fixed by #11303
Closed

Router's rootURL isn't working in 1.12 beta #10943

tcjr opened this issue Apr 23, 2015 · 35 comments · Fixed by #11303
Milestone

Comments

@tcjr
Copy link

tcjr commented Apr 23, 2015

I'm having a problem with the router in 1.12.0-beta.1. I'm attempting an upgrade from 1.11.

None of my routes are being recognized, and I believe it is because of this pr: #10483 . It looks like the router is no longer accommodating a rootURL. Our router is defined like this:

var Router = Ember.Router.extend({
  rootURL:  '/somepath/'
});

If I step through the router code, I see that the rootURL is still attached when it goes into the code trying to find a handler, and (unsurprisingly) can't find any.

@tcjr
Copy link
Author

tcjr commented Apr 28, 2015

I've adapted one of @rwjblue jsbins to demonstrate the UnrecognizedURLError:

http://emberjs.jsbin.com/qivevu/1/edit?html,js,output

@himynameisjonas
Copy link

I have the same problem, couldn't test glimmer/canary with my app because of this issue

@matthooks
Copy link
Contributor

+1 on not being able to test glimmer/canary because of this.

@rwjblue
Copy link
Member

rwjblue commented May 6, 2015

@tcjr - That JSBin has roughly the same error in 1.11.3. http://emberjs.jsbin.com/nubotu/1/edit.

I have no doubt that this is broken, I am just trying to get a minimal reproduction to start debugging.

@jesenko
Copy link

jesenko commented May 7, 2015

The error can be reproduced by creating new ember-cli app and just setting rootURL to some value - see https://github.com/jesenko/root-url-bug for example.

When using ember 1.11.3, localhost:4200/test/ works, with ember 1.12.0-beta.3 it fails with

UnrecognizedURLError: /test/

@himynameisjonas
Copy link

Ok, got the app working by adding url = url.replace(this.get('rootURL'), ''); to the handleURL method in the ember router. I don't feel comfortable enough with the ember source code to do anything more (like a test and PR).

But now, I can at least start working on the deprecation warnings my app have :)

@tcjr
Copy link
Author

tcjr commented May 12, 2015

@rwjblue I think my jsbin might not be illustrating the problem correctly. I cannot get any routes in my app to work if a rootURL is set on the router.

@gpoitch
Copy link
Contributor

gpoitch commented May 14, 2015

This is only broken with 'auto' location. 'history' location is still working correctly.

@rwjblue
Copy link
Member

rwjblue commented May 14, 2015

@gdub22 - Awesome, thank you for confirming!

@rwjblue
Copy link
Member

rwjblue commented May 14, 2015

That means this is almost certainly a result of #10483 (which mostly modified auto-location).

@himynameisjonas
Copy link

This is still an issue in the released 1.12 version, but as @gdub22 said: it works with location: 'history'.

@tcjr
Copy link
Author

tcjr commented May 15, 2015

Does this mean location: 'auto' is no longer supported?

@mixonic
Copy link
Member

mixonic commented May 15, 2015

this is definitely a regression

@davidpett
Copy link
Contributor

having the issue as well with location: 'auto' my app loads at the correct rootURL, then quickly replaces with /, the app still runs as normal, but obviously at the wrong rootURL.

I just switched to location: 'history' and it works as expected, so can confirm it has to do with auto-location

@MichaelVdheeren
Copy link

This needs a quick fix

@rwjblue rwjblue added this to the 1.12.1 milestone May 21, 2015
@MichaelVdheeren
Copy link

Any idea when 1.12.1 will be out? This bug is in since beta 1

@rwjblue
Copy link
Member

rwjblue commented May 28, 2015

We could release 1.12.1 anytime (there are a few other fixes already queued up in the release channel), but this bug isn't fixed. I would prefer to have this fixed before releasing.

@MichaelVdheeren
Copy link

Could the error be on line 122 here: https://github.com/emberjs/ember.js/pull/10483/files#diff-782353730e67c473ee6609c98230661dR122

Either way this resolves to true or false and not to the location...

Update: my bad, it does resolve to the last value, thx rwjblue to hand me a pair of glasses for my eyes ;-)

@rwjblue
Copy link
Member

rwjblue commented May 28, 2015

Why would it be true or false? In general doing && like that returns the last truthy value...

var foo = { bar: 'stuff'};
var bar = null;

foo && foo.bar // => 'stuff'
bar && bar.bar // => undefined

See demo: http://emberjs.jsbin.com/rwjblue/561/edit

@acorncom
Copy link
Contributor

@rwjblue Really appreciated 👍 Would love to have been able to help on this one ... :-/

@jayphelps
Copy link
Contributor

Feel free to ping me in the future on location class issues, particularly with auto.. It's too bad this was broken for a month..had I heard I would have PR'd immediately to fix. Thanks @rwjblue for fixing!

@davidpett
Copy link
Contributor

@rwjblue @jayphelps I just tested ember#beta and this seems to be an issue again, not sure why. ember#release is working fine now

@rwjblue
Copy link
Member

rwjblue commented Jun 11, 2015

@davidpett - Can you provide steps to reproduce?

@davidpett
Copy link
Contributor

I'll work up a demo repo and link to it. Should have done it first, sorry.

On Thu, Jun 11, 2015 at 4:47 PM Robert Jackson notifications@github.com
wrote:

@davidpett https://github.com/davidpett - Can you provide steps to
reproduce?


Reply to this email directly or view it on GitHub
#10943 (comment).

@rwjblue
Copy link
Member

rwjblue commented Jun 11, 2015

Should have done it first, sorry.

No worries really, I just want to make sure we are on the same page as to what we are talking about. It took me a bit of time to replicate this issue in ember-cli originally because if you use baseURL it didn't occur (due to browser default behavior with the <base> tag).

@jayphelps
Copy link
Contributor

Happy to investigate with reproduction steps. I'll take a look at diff and see if I see anything suspicious.

@davidpett
Copy link
Contributor

@rwjblue @jayphelps https://github.com/davidpett/auto-location-base-url

i removed the base tag.

i get the same issue in beta as i did in 1.12.0, but that was fixed in 1.12.1

@jayphelps
Copy link
Contributor

@davidpett @rwjblue figured it out. The beta has not yet gotten this fix #11303. Basically, the concrete location class isn't getting rootURL in beta so it's not be excluded from the route recognizer.

Thanks for the demo app! Would have taken a lot longer to find this without it.

In ember#beta

image

In ember#canary

image

App runs fine with ember#canary.

@davidpett
Copy link
Contributor

awesome! it's a little harder with ember-cli and some of these issues, can't simply do a jsbin anymore

thanks

@davidpett
Copy link
Contributor

@rwjblue any chance of getting that PR merged into the beta branch before 1.13 release tomorrow?

@acorncom
Copy link
Contributor

@davidpett Re: ember-cli, no jsbin, there is a work-in-progress on that here: http://twiddle.joostdvrs.com Might be helpful ...

@davidpett
Copy link
Contributor

Yeah @acorncom, it's not there yet, but good start. Faster to run cli and create demo app

@acorncom
Copy link
Contributor

@davidpett Sounds good, good to know ;-)

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

Great catch, sorry about the extra work tracking down my mistake :(

It is cherry-picked into beta now.

@davidpett
Copy link
Contributor

confirm that it works, thanks @jayphelps for finding it and @rwjblue for pushing it!

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

Successfully merging a pull request may close this issue.