pwa-helpers icon indicating copy to clipboard operation
pwa-helpers copied to clipboard

Router crashes if port number changes

Open Avocher opened this issue 7 years ago • 3 comments

We have a dev server for handling local signin that is on separate port. This seems to crash the router with the following message:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'https://localhost:9080/xxxxx' cannot be created in a document with origin 'https://localhost'

Thanks for you this great library!

Avocher avatar Jul 02 '18 12:07 Avocher

@Avocher Do you have a simple test that we can run to reproduce the issue?

frankiefu avatar Jul 12 '18 20:07 frankiefu

Could be on IE where window.location.origin doesn't exist and we build our own:

    const location = window.location;
    const origin = location.origin || location.protocol + '//' + location.host;
    if (href.indexOf(origin) !== 0) return;

To fix, we need to account for port number, but bear in mind most hrefs don't contain the default port number. For full IE support the implementation would look more like iron-location.

(Or, better yet, don't use IE)

keanulee avatar Jul 20 '18 19:07 keanulee

(Or, better yet, don't use IE)

I'll just leave this here... 😇

# Redirect Internet Explorer users to Chrome download page
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_USER_AGENT} (MSIE|IE11|Trident\/7\.) [NC]
  RewriteRule ^(.*)$ https://www.google.com/chrome/ [NC,L,R]
</IfModule>

PS: Not saying this is necessarily a good idea haha

jsilvermist avatar Jul 20 '18 21:07 jsilvermist