Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A cross-origin url on _coverpage file cannot be redirected to if "routerMode" is set to "history" #1379

Closed
1 task done
BeamerIsHere opened this issue Oct 1, 2020 · 5 comments
Assignees

Comments

@BeamerIsHere
Copy link

BeamerIsHere commented Oct 1, 2020

Bug Report

Steps to reproduce

Set these lines in index.html

  window.$docsify = {
    //...
    loadSidebar: true,
    routerMode: 'history',
    coverpage: true,
    onlyCover: true,

Then use any other doman URLs in _coverpage file, See below...

<a href="https://rstudio.com/auth-sign-in">Login</a><br />

What is the current behavior

when clicking on the link on the cover page there is no response, while checking the browser console getting the following error.

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'https://rstudio.com/auth-sign-in' cannot be created in a document with origin 'https://datatools.inhouse.com' and URL 'https://datatools.inhouse.com/'.
at https://cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js:1:93866

What is the expected behavior

Redirect to the mentioned web page directly.

Other relevant information

  1. search.min.js
  2. docsify-plugin-flexible-alerts
  3. mermaid.js

Mentioned index.html and _coverpage files are in the below repository. Please check it.

Git repo

Mention the docsify version in which this bug was not present (if any)

@Siddhu1096
Copy link

Siddhu1096 commented Oct 1, 2020

I'm also facing the same issue.

Sent from my OnePlus 5 using FastHub

@vergilcw
Copy link

vergilcw commented Oct 1, 2020

Yes, I have noticed this issue as well--I use some custom html in my coverpage, and standard html anchor links do nothing when you click on them, if router mode is set to "history". The same links work fine in "hash" routing mode.

It looks like another Docsify user may have solved this with a custom plugin, but I'm not sure if it is possible to generalize: ml5js/ml5-library#985
ml5js/ml5-library@f5ba5d7

@Koooooo-7
Copy link
Member

Koooooo-7 commented Oct 6, 2020

Thx for ur report.
Actually, we support this case but we hvnt document it yet.
Absolutely, you can use the same way as @vergilcw mentioned in docsify.
you just need config all the cross origin links below, and I think it will work as u expect :).

window.$docsify = {
  crossOriginLinks:[
      "https://rstudio.com/auth-sign-in",
   ],
};

@BeamerIsHere
Copy link
Author

BeamerIsHere commented Oct 7, 2020

@Koooooo-7 Thank you for the solution, I tried the same and it worked as expected.

I've solved the issue differently using href attribute '"target="_blank'. See below.

<a href="https://rstudio.com/rsc/connect/#/login/" target="blank">

Adding the '"target="_blank' with the URL solved the issue by opening it in a different browser tab.

@Koooooo-7
Copy link
Member

@Koooooo-7 Thank you for the solution, I tried the same and it worked as expected.

Aha, no problem.

I've solved the issue differently using href attribute '"target="_blank'. See below.

<a href="https://rstudio.com/rsc/connect/#/login/" target="blank">

Adding the '"target="_blank' with the URL solved the issue by opening it in a different browser tab.

Cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants