Skip to content

Router - SecurityError: Failed to execute 'pushState' #5218

Closed

Description

Hello,

When using PathLocationStrategy I get the error:

EXCEPTION: SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'http://about-us/' cannot be created in a document with origin 'http://localhost:3000'.

When I use HashLocationStrategy it works fine.

I'm working with angular 2.0.0-alpha.45

Thanks

Activity

  1. ericmartinezr commented on Nov 11, 2015

    @ericmartinezr
    Contributor

    @jvbianchi it sounds like you are missing something. The URL that is trying to create it should be relative to your path. Did you specify <base href="..." /> tag? Or at least APP_BASE_HREF? It looks like it needs it, showing us your code would be super useful :)

  2. luongvancuong commented on Oct 10, 2016

    @luongvancuong

    Uncaught SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'file:///E:/design' cannot be created in a document with origin 'null' and URL 'file:///E:/important/html_website_gtg/html/animation.html'

    who can help me? Please. Thanks so much.

  3. zoechi commented on Oct 10, 2016

    @zoechi
    Contributor

    @luongvancuong use an HTTP server instead of direct file access

  4. damnko commented on Apr 7, 2017

    @damnko

    I am having the same issue while trying to pack an app with Electron. It occurs both with { useHash: true } and { useHash: false }. Using an HTTP server solves the problem but I would prefer to avoid this solution as I would need to ship that too with Electron.

    @zoechi do you know if there's any other solution? Any hint of what's the root cause of the problem? Is the angular router causing it? Testing Electron with other apps with no navigation gives me no problem so I was wondering why it's happening on mine.

    @luongvancuong did you manage to solve it without an HTTP server?

    Thanks!

    edit: <base href="."> is defined

  5. angular-automatic-lock-bot commented on Jun 2, 2021

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions