Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Navigation via url/refresh/link other than sidenav does not work in production mode. #148

Closed
Swapnull opened this issue Jul 18, 2018 · 6 comments
Labels
bug Something isn't working

Comments

@Swapnull
Copy link
Contributor

Bug Report

When the project has been built for production using yarn docz build navigation only works through the side bar. When trying to link between pages using markdown links, or refreshing the page, the site 404's.

To Reproduce
Here is what I used to test -
First I load the typography page successfully by using the sidebar nav, it loads successfully.
Next I try to refresh the page and it 404's.
Then I navigate to the colors page and it loads successfully.
Next I try to refresh the page and it 404`s.

[Wed Jul 18 2018 14:29:58 GMT+0100 (BST)] "GET /static/js/docs-1-brand-2-typography.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
[Wed Jul 18 2018 14:30:04 GMT+0100 (BST)] "GET /brand/typography" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
[Wed Jul 18 2018 14:30:04 GMT+0100 (BST)] "GET /brand/typography" Error (404): "Not found"
[Wed Jul 18 2018 14:30:31 GMT+0100 (BST)] "GET /brand/colors" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
[Wed Jul 18 2018 14:30:31 GMT+0100 (BST)] "GET /brand/colors" Error (404): "Not found"

Expected behavior
That the routes are served so they can be accessed from anywhere, not just from the sidebar navigation.

Enviroment

  • OS: OSX 10.13.4
  • Node/npm version: Node 9, NPM 5
  • Docz Version: 0.5.9
@mAAdhaTTah
Copy link

Not to piggy-back on all your issues, but in development mode, it does a full page refresh, whereas the sidebar triggers a rerender. Could be related.

@pedronauck pedronauck added the bug Something isn't working label Jul 19, 2018
@pedronauck
Copy link
Member

pedronauck commented Jul 19, 2018

I think that it's a problem related to this issue: #25
Some solution is set the hashRouter property on your config to create a hash navigation, or you can configure your static server to redirect always to your index.html

To link documents on your markdown, you need to use the docz Link component

import { Link } from 'docz'

<Link to="/some/path">my link</Link>

I'm really like this post that explains very well about this
https://tylermcginnis.com/react-router-cannot-get-url-refresh/

@mAAdhaTTah
Copy link

To link documents on your markdown, you need to use the docz Link component

It might be nice to enable internal linking with standard Markdown. I noticed the docz site itself does full page reloads when linking in the content.

@pedronauck
Copy link
Member

pedronauck commented Jul 19, 2018

Yes, docz site has full page reload because we are doing an index.html redirecting using Netlify @mAAdhaTTah

@Swapnull
Copy link
Contributor Author

Switching from using Markdown links to <Link> fixes the issue.
I have also applied the same netlify.toml from the docz site to do the index.html redirect and that sorts out the refresh :)
Not sure that is really a solution, but it works for me.

@rupification
Copy link

@pedronauck
i think this might still exist in prod mode.

hosting the dist using http-server and hitting abc.com/getting-started will return 404. hitting abc.com without the path works though.

im using v1 rc7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants