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

routing path refresh leads to 404 #62

Closed
aaronmallen opened this issue Nov 27, 2018 · 12 comments
Closed

routing path refresh leads to 404 #62

aaronmallen opened this issue Nov 27, 2018 · 12 comments
Labels
bug critical docma-web Fixed or implemented. To be released.

Comments

@aaronmallen
Copy link

aaronmallen commented Nov 27, 2018

Using app.routing path will result in 404 on page refresh. links in the nav menu will take you to the expected page but on page refresh a trailing / is added to the url and a 404 Page not found is displayed.

{
  "src": [
    {
      "interface": [
        "./src/**/*.js",
        "!./src/internal/**"
      ],
      "internal": [
        "./src/internal/**/*.js"
      ],
    },
    "./LICENSE:md",
    "./CHANGELOG.md",
    "./CODE_OF_CONDUCT.md",
    "./CONTRIBUTING.md",
    "./docs/**/*.md"
  ],
  "dest": "./docs/.out",
  "app": {
    "title": "MyLib",
    "entrance": "content:readme",
    "server": "github",
    "routing": "path"
  },
  "template": {
    "navbar": {
      "menu": [
        {
          "label": "Docs",
          "iconClass": "fas fa-book",
          "items": [
            {
              "label": "Getting Started",
              "href": "/content/getting_started"
            },
            {
              "label": " API",
              "href": "/api/interface",
              "iconClass": "fas fa-code fa-sm"
            },
            {
              "label": "Lib",
              "href": "/api/internal",
              "iconClass": "fab fa-dev fa-sm"
            }
          ]
        }
      ]
    }
  }
}
$ node -v
v10.13.0
$ npm -v
6.4.1
$ node_modules/.bin/docma -v

3.0.0
@aaronmallen aaronmallen changed the title refresh leads to 404 routing path refresh leads to 404 Nov 27, 2018
@onury
Copy link
Owner

onury commented Dec 1, 2018

You have "entrance": "content:readme" but you don't have any route named readme in your src.

AND Pls read the docs thoroughly before opening multiple issues you're not sure of. I'm providing these open source projects for free but I don't have that much free time. So please read the docs...

@onury onury closed this as completed Dec 1, 2018
@aaronmallen
Copy link
Author

@onury readme.md is in docs/ please reopen

@aaronmallen
Copy link
Author

Also Readme loads fine the issue is with the two api paths

@onury onury reopened this Dec 1, 2018
@onury
Copy link
Owner

onury commented Dec 1, 2018

Try updating your hrefs without a leading slash (/) which results in an absolute path rather than relative. e.g. "api/interface" instead of "/api/interface".

@aaronmallen
Copy link
Author

Lastly I appreciate you and this project and have read the docs extensively both from your site AND from the source itself ;)

@aaronmallen
Copy link
Author

Still reproducible when using relative paths in the config. To be clear its not a generic 404 thats being loaded its a docma generated page for 404 with the nav and everything still present. You can even just click the link from the nav to make it redirect to the right page.

To reproduce:

  1. set app.routing to path in your config
  2. have 2 "named" api's (i.e. 'api1', 'api2') in the src of your config
  3. docma serve and goto localhost:9000
  4. attempt to goto localhost:9000/api/api1 or use a link in the navigation to go to 'api1'

When using a link from the navigation the page will load, but upon refresh a trailing / will be appended to the url and a 404 is returned, when attempting to go directly to the page via url a trailing / will be appended to the url and a 404 returned.

So for example: http://localhost:9000/api/api1#MyModule.myFunctionwill be http://localhost:9000/api/api1/#MyModule.myFunction after or refresh or when trying to access the url directly.

@aaronmallen
Copy link
Author

Uncaught Error: Page or content not found for route: {}
    at docma-web.js:38
    at Stub.callback (docma-web.js:38)
    at Stub.flush (docma-web.js:4)
    at Chunk.setError (docma-web.js:4)
    at Object.dust.render (docma-web.js:4)
    at DocmaWeb._render (docma-web.js:38)
    at DocmaWeb._render404 (docma-web.js:38)
    at DocmaWeb.render (docma-web.js:38)
    at DocmaWeb.Route.apply (docma-web.js:40)
    at docma-web.js:49

@onury
Copy link
Owner

onury commented Dec 2, 2018

This is a bug in the core dependency page.js.
I've opened an issue there and also sent a PR to fix it.

If they don't merge this soon, I'll use my fixed version of page.js in the new Docma release (that has some other fixes).

Thanks for reporting.

@onury onury added Fixed or implemented. To be released. docma-web labels Dec 2, 2018
@onury
Copy link
Owner

onury commented Dec 3, 2018

Fixed in Docma 3.1.0.
Let me know if it works for you.

@onury onury closed this as completed Dec 3, 2018
@aaronmallen
Copy link
Author

Works great! Thank you @onury

@chepitoco
Copy link

chepitoco commented Jan 22, 2019

I have this docma json file test:

{ "src": [ "./src/components/**/*.js", "./README.md" ], "dest": "./src/docs" }

When I execute, yarn docma -c docma.json it works but when I visit the generated index.html I'm getting the following:
screen shot 2019-01-22 at 10 54 49 am

The same error: Uncaught Error: Page or content not found for route: {}

I have "docma": "^3.2.2", in my package json. I'm not sure if I need to configure something else, it's just a simple test.

Best regards.

@onury
Copy link
Owner

onury commented Jan 22, 2019

You cannot view the generated app by opening (double-clicking) the index.html. You need to serve the app locally to test it. You can use docma serve command.

And according to your docma.json config, you should have these routes:

  • <your-docs-root>/?api : generated from your .js files
  • <your-docs-root>/?content=readme : generated from README.md

Please read the documentation and F.A.Q. section is also helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug critical docma-web Fixed or implemented. To be released.
Projects
None yet
Development

No branches or pull requests

3 participants