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

Problem using direct links (live/prod only) #2190

Closed
bravo-kernel opened this issue Jan 5, 2020 · 22 comments
Closed

Problem using direct links (live/prod only) #2190

bravo-kernel opened this issue Jan 5, 2020 · 22 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: trailing slash Related to trailing slash config

Comments

@bravo-kernel
Copy link
Contributor

Intro

It "looks like" there is a bug in production with direct links/routing(?).

  • only occurs on live/production sites
  • no errors when running locally using yarn start
  • also, all pages used as examples below work fine when accessing them through the site (start at landing page, then click-through using menu of in-site links)

Reproducable Error A

  1. Browse to https://pester.dev/docs/commands/Describe

Problem 1: no left side-bar
Problem 2: uppercase Describe is being lowercased

Reproducable Error B

  1. Browse to https://pester.dev/docs/contributing/introduction
  2. Click on link "How to File an Issue"

Problem: 404 error

Versions

Redux Toolkit uses v0.35 which also has the same problem.

Try browsing to this link https://redux-toolkit.js.org/api/getDefaultMiddleware.

Ping @markerikson

@bravo-kernel bravo-kernel added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 5, 2020
@Victorkangsh
Copy link

Same error, the version is 2.0.0-alpha.40.

@markerikson
Copy link

Hmmm. Agreed that something is definitely going on with that RTK link, but it seems like only a few pages are being affected. I also tried it with a few Redux core docs pages like https://redux.js.org/api/combinereducers , and they seem to work okay.

If I open that link, I do see the left sidebar very briefly, and then it hides itself.

@bravo-kernel
Copy link
Contributor Author

bravo-kernel commented Jan 11, 2020

Root Cause Found

  1. only pages with mixed-case frontmatter id field are affected by this problem
  2. only the built/live/production site lowercases URL

This is also why the local version has no issues, the URL does not get lowercased there

Help Needed

I am no pro, especially when it comes to the server side of Docusaurus. Hopefully this is enough information for someone to chip in and help solve this problem ❤️

@lex111
Copy link
Contributor

lex111 commented Jan 20, 2020

  1. This redirect does your hosting provider. Accordingly, this is not a D2 problem.
  2. Use URL with trailing slash only.

When you go to direct links, Docusaurus does not manage this (redirects, trailing slashes), this is a static site, so the requested URL is important here, these problems depends on hosting platforms you use.

Try installing this package locally https://www.npmjs.com/package/serve, build a website and run the serve /build command - everything will become clearer.

@bravo-kernel
Copy link
Contributor Author

bravo-kernel commented Jan 20, 2020

Thanks for explaining this @lex111, I will invest the time to make this clear/learn.

It would be great if this is indeed a hosting issue (Netlify in this case).

@bravo-kernel
Copy link
Contributor Author

@bravo-kernel
Copy link
Contributor Author

@lex111 thank you for helping us out here ❤️. Looking at this I guess the only real solution for Netlify users would be using lowercase ids.

I will do some testing and if I can confirm, will propose a documentation PR advizing users to use lowercase ids to prevent issues with e.g. Netflify.

@lex111
Copy link
Contributor

lex111 commented Jan 20, 2020

@bravo-kernel although maybe this is still a D2 problem, since our blog entry looks similar - https://v2.docusaurus.io/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus -> https://v2.docusaurus.io/blog/2018/04/30/how-i-converted-profilo-to-docusaurus/ (redirect by Netlify)

And it works OK. I will try to do something with this, in the end we need to "simple" bring back the doc sidebar. But my personal opinion is that this kind of problem is the responsibility of the end-user (and its hosting provider). I do not promise, but I will try to do a workaround for this. (after all, I'm not pro either 😄)

@lex111
Copy link
Contributor

lex111 commented Jan 21, 2020

@bravo-kernel I have created PR #2235. This patch should show the doc sidebar when going to the wrong URL path.

@bravo-kernel
Copy link
Contributor Author

Copied from a Netlify notification email:

Will this impact my SEO?

No. Forwarding traffic to a new domain extension using a 301 redirect is a proven technique that search engines are well aware of. Your inbound links will not be affected. Your search engine rankings will not be affected.

@bravo-kernel
Copy link
Contributor Author

Confirmed as fixed in 2.0.0-alpha.41. Thanks @lex111 👏

@markerikson
Copy link

Can you clarify what the actual fix is?

I was seeing the issue with a Redux Toolkit alpha API page yesterday, and tried deploying alpha.41. Afterwards, it looked like the behavior was basically the same. The left sidebar flashes briefly, then disappears.

Example link:

https://deploy-preview-352--redux-starter-kit-docs.netlify.com/api/createEntityAdapter

@bravo-kernel
Copy link
Contributor Author

bravo-kernel commented Feb 17, 2020

Are you sure you are running .41.

In my case the above mentioned PR now adds the sidebar when netlify redirects

https://docusaurus-powershell.netlify.com/docs/commands/New-DocusaurusHelp

to

https://docusaurus-powershell.netlify.com/docs/commands/new-docusaurushelp/

@markerikson
Copy link

Hmm.

I coulda sworn I did merge in alpha.41 last night, but I was also doing it at 2 AM, and I see alpha.40 at the tip of the current PR branch I'm working on:

https://github.com/reduxjs/redux-toolkit/blob/9842933e6a04d7ad83ef32911129b25f0798ba53/website/package.json

Lemme check this again this evening and confirm.

@bravo-kernel
Copy link
Contributor Author

OK, I am seeing some issues with css not loading in the lowercase version atm but that could be my local browser.

You might be able to reproduce if you open a new browser window and then pasting my lowercased URL https://docusaurus-powershell.netlify.com/docs/commands/new-docusaurushelp/

@bravo-kernel
Copy link
Contributor Author

Not happening when opening a private window.

@markerikson
Copy link

markerikson commented Feb 18, 2020

Yeah, this does not appear to be solving the problem for the Redux Toolkit docs. Example as of right now, on alpha.41:

https://deploy-preview-352--redux-starter-kit-docs.netlify.com/api/createAsyncThunk

And the deployed package.json for that PR preview:

https://github.com/reduxjs/redux-toolkit/blob/a0aeacef0e55bc0fdf9c1135d5175bcd3feed821/website/package.json

To make things worse, alpha.41 appears to be breaking column widths on some of the pages, with the content column filling the entire page, and the right-hand page TOC being shoved to the bottom.

@lex111
Copy link
Contributor

lex111 commented Feb 18, 2020

@markerikson I just made a small fix and deployed your website, so everything should be OK https://hardcore-hermann-669593.netlify.com/api/getdefaultmiddleware/

@bravo-kernel
Copy link
Contributor Author

@lex111 I can only speak for my own website but v43 solved all issues. Thanks for the quick fix 💯

@markerikson
Copy link

This is still somehow not working right, at least on a specific PR branch.

This version, from the PR that added .43, works fine:

https://deploy-preview-369--redux-starter-kit-docs.netlify.com/api/getdefaultmiddleware/

I merged that PR to master, and then merged master into a larger WIP PR with code changes. However, that version does not work okay even after I merged in .43:

https://deploy-preview-352--redux-starter-kit-docs.netlify.com/api/getdefaultmiddleware/

Why are these not behaving the same?

@markerikson
Copy link

Scratch that last comment.

I just tried clearing the Netlify cache and forcing a redeploy, and now, finally, the PR 352 preview link looks correct:

https://deploy-preview-352--redux-starter-kit-docs.netlify.com/api/getdefaultmiddleware/

  • Sidebar on left side even though we went straight to the page URL
  • Page TOC on the right side
  • Content is the correct width

So, I'm going to claim this is indeed good to go now.

Thanks for poking at this enough to fix things!

@bravo-kernel
Copy link
Contributor Author

bravo-kernel commented Mar 14, 2020

Netlify users: make sure to disable PrettyURLs (to prevent lowercased-URL 301 redirects and added-trailing-slash 404 errors). See #2394 (comment)

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Apr 8, 2022
@Josh-Cena Josh-Cena added the domain: trailing slash Related to trailing slash config label Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: trailing slash Related to trailing slash config
Projects
None yet
Development

No branches or pull requests

5 participants