-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Back button broken in Chrome when setting location.href in HTML5 mode #11667
Comments
Hello, |
I've reproduced this here: http://public.jacklab.co.za/ |
Click the link, then click back. |
In reproducing this I noticed that this only happens when the next page is navigated to by setting window.location.href. The reason for doing this is that the router at / sometimes intercepts links pointing to pages under the router at /app. Setting window.location.href allows me to bypass the router at /. |
Also, this error does not happen in Firefox. I've only confirmed the bug in chrome 41. |
@petebacondarwin I assigned you since you said you where looking into location issues, hope that's okay. |
@circlingthesun - I think we may have fixed this bug in 6903b5e. I copied down your reproduction of the issue to localhost but I couldn't get it to fail. Are you doing something clever on your server? Can you try out the version at https://code.angularjs.org/snapshot? |
I just updated the code to point the snapshot but the error still happens. I'm not doing anything fancy on the server. The site resolves to index.html and /app resolves to app.html. My nginx config is as follows:
|
OK, so here is a failing Plunker: http://plnkr.co/edit/wQ7WxkIPTL1L8p5VnkxR?p=preview |
If you use target="_self" then you don't need the |
That'll work when there is a link. In my actual codebase I have a login modal that redirects to /app. Is there perhaps another way to get around this? |
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes angular#11667
@circlingthesun - can you take a look at my proposed fix: #12361 |
This does appear to fix the issue. (see http://public.jacklab.co.za/) |
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes angular#11667
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes #11667
Closed by 9e492c3 |
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes angular#11667
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes #11667
Previously, if you navigate outside of the Angular application, say be clicking the back button, the $location service would try to handle the url change and error due to the URL not being valid for the application. This fixes that issue by ensuring that a reload happens when you navigate to a URL that is not within the application. Closes angular#11667
When clicking a link from
http://example.com/
tohttp://example.com/app
where/app
runs angular with HTML5 mode and the baseURL set to/app
, the following error is raised when you press the back button:Error: [$location:ipthprfx] Invalid url "http://example.com/", missing path prefix "http://example.com/app/"
The offending line:
var pathUrl = beginsWith(appBaseNoFile, url);
Can be found here:
angular.js/src/ng/location.js
Line 107 in a509e9a
pathUrl
returns undefined which results in an error being thrown and the page not navigating back tohttp://example.com/
as expected.The text was updated successfully, but these errors were encountered: