In my js file:
window.history.pushState('','',slug);
I know about security restrictions for the pushState method:
The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception.
However, in my website I use a domain: www.mydomain.com
where pushState works fine. But when I call the method on my subdomain subdomain.mydomain.com
, it throws a weird exception:
Uncaught SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'http://0.0.7.210/' cannot be created in a document with origin 'http://subdomain.mydomain.com'.
I do call the IP 0.0.7.210 as something internal but I get this exception on development + live environment.
I do resolve my subdomains via Route53 by the way. Maybe it has to do with that?
It turned out that pushing an additional /
solved the issue.
Changed this
window.history.pushState('','',slug);
to this
window.history.pushState('','','/'+slug);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With