Polymer / pwa-helpers

Small helper methods or mixins to help you build web apps.
BSD 3-Clause "New" or "Revised" License
439 stars 48 forks source link

Router crashes if port number changes #33

Open Avocher opened 6 years ago

Avocher commented 6 years ago

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!

frankiefu commented 6 years ago

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

keanulee commented 6 years ago

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)

jsilvermist commented 6 years ago

(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