question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A cross-origin url cannot be redirected to if "externalLinkTarget" is set to "_self" and "routerMode" is set to "history"

See original GitHub issue

Bug Report

Steps to reproduce

Set the options firstly:

window['$docsify'] = {
  routerMode: 'history',
  externalLinkTarget: '_self'
}

Then write a link whose url is from another domain:

Example: [example.com](https://example.com/)

What is current behaviour

If our domain were docsify.now.sh, it would do nothing and pop an error on the debug console:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'https://example.com/' cannot be created in a document with origin 'https://docsify.now.sh' and URL 'https://docsify.now.sh/'.
    at https://unpkg.com/docsify@4.10.2/lib/docsify.min.js:1:61459

The corresponding source code is here.

What is the expected behaviour

Redirect to https://example.com/ normally.

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: Linux ZZZ-PC-4 5.4.0-4-amd64 #1 SMP Debian 5.4.19-1 (2020-02-13) x86_64 GNU/Linux

  • Node.js version: v12.14.0

  • npm/yarn version: 6.13.4

  • Browser version: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36

  • Docsify version: 4.10.2

  • Docsify plugins: None

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Koooooo-7commented, Sep 30, 2020

@BeamerIsHere thx for ur report! Could you please open a new issue to let us check it in process ? somehow, I can’t open ur sites to check the configurations, so I guess u need provide ur repo also in case of the site is unavailable. or u can make it in Sandbox.

0reactions
BeamerIsHerecommented, Sep 29, 2020

@Koooooo-7 @anikethsaha I’ve got the same issue with external links.

I have a _coverpage file and added some external links to it and also enabled history routing mode. Getting the same error. Since I have the links in the _coverpage file( not in MD), I’m confused by the solutions above.

I’ll add my coverpage and index.html file here.

Thanks in advance!

Getting this error

“Uncaught DOMException: Failed to execute ‘pushState’ on ‘History’: A history state object with URL ‘https://tfs.insidenci.com/Energy-=contents’ cannot be created in a document with origin ‘http://127.0.0.1:5500’ and URL ‘http://127.0.0.1:5500/docs-home’.”

Index page

<!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="UTF-8"> <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
<style>
    .sidebar::-webkit-scrollbar {
        width: 10px;
    }/* ... */
    .center {
        margin-left: auto;
        margin-right: auto;
    }
    img.cover {
        width: 100;
        height: 100;
    }
</style>
</head> <body> <div id="app"></div>
<script>
  
  window.$docsify = {
    //...
    loadSidebar: true,
    routerMode: 'history',
    externalLinkTarget: '_self',
   
    alias: {
      '/.*/_sidebar.md': '/_sidebar.md',
    },
    subMaxLevel: 3,
    relativePath: false,
    //homepage: 'docs-home.md',
    name: '',
    coverpage: true,
    onlyCover: true,
    // create custom headings for Flexible Alerts
    'flexible-alerts': {
      note: {
        label: "Note"
      },
      tip: {
        label: "Tip"
      },
      warning: {
        label: "Caution"
      },
      danger: {
        label: "Attention"
      },
      style: 'callout'
    },  
   
    plugins: [
  function(hook, vm) {
  hook.beforeEach(function(html) {
    var url =
      'https://somelink.com/'.concat(vm.route.file,"&version=GBmaster&_a=contents") ;
    var editHtml = '[Edit this page](' + url + ')\n';
    return (
      html +
      '\n----\n' +
      editHtml 
    );
  });
}
]

  }
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<!-- plugins -->

<!-- collapse the sidebar automatically -->
<script src="//unpkg.com/docsify-sidebar-collapse/dist/docsify-sidebar-collapse.min.js"></script>
<!-- enable search bar -->
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<!-- enable "copy code" button on code chunks -->
<script src="https://unpkg.com/docsify-copy-code@2"></script> -->
<!-- enable flexible alerts plugin https://github.com/fzankl/docsify-plugin-flexible-alerts -->
<script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script>
<!-- Enable mermaid diagrams -->
<script src="//unpkg.com/mermaid/dist/mermaid.js"></script>
<script src="//unpkg.com/docsify-mermaid@latest/dist/docsify-mermaid.js"> 
<script>mermaid.initialize({ startOnLoad: true });</script>
</body> </html>

Coverpage

logo

Data Tools Landing Page

<div class="center" style="text-align: justify; max-width:600px"> Welcome to the Data Tools Landing Page for Advanced Solutions. Here you will find access to and documentation for (almost) all the data management, analytics, modeling and visualization tools supported by Advanced Solutions. Please reach out on Teams if you have any questions or concerns. </div>    

Analytics

RStudio Server
Login
Docs

Warehousing

Snowflake
Login
Docs

Visualization

Spotfire
Dev|Test|UAT|Prod
Docs
RStudio Connect
Login
Docs

Collaboration

Azure DevOps
Login
Docs
MS Teams
Login
Docs
       

Go to TechDocs

color

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to follow redirections on a cross origin request with no ...
Sometimes, we just need the redirection to occur even though we cannot access the response. This article shows how you make the browser...
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, or...
Read more >
Cross-origin redirection denied by Cross-Origin Resource ...
domain-c is the domain where the request is finally redirected to. First of all, I think, you want to make a workaround. As...
Read more >
The Ultimate Guide to Redirects: URL Redirections Explained
Website owners often set up redirects for pages that are broken, contain duplicated content, or were moved to new URLs.
Read more >
Navigations - XS-Leaks Wiki
Check the value of history.length, which is accessible through any ... Set the destination URL to test for the download attempt var url...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found