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

404 error with a different http server for sidebar files #1713

Open
1 task
CxRes opened this issue Jan 5, 2022 · 11 comments
Open
1 task

404 error with a different http server for sidebar files #1713

CxRes opened this issue Jan 5, 2022 · 11 comments
Labels
bug confirmed as a bug

Comments

@CxRes
Copy link

CxRes commented Jan 5, 2022

Bug Report

I am using a different server than the one provided by docsify-cli (http-server) because of docsifyjs/docsify-cli#32. I find that the server keeps complaining about missing sidebar file for each route even though I have set a global sidebar file. Like so:

 "GET foo/docs/bar/_sidebar.md" Error (404): "Not found"

The pages however work fine with the global sidebar loaded.

Steps to reproduce

Configurations that I have tried:

  1. Original
    Files are in /foo/docs
    Homepage is /foo/docs/bar/README.md
    I have a static sidebar at /foo/docs/_sidebar.md
window.$docsify = {
      name: 'foo',
      alias: {
        '/':'/bar/',
      },
      basePath: '/foo/docs/',
      relativePath: false,
      loadSidebar: '_sidebar.md',
     ...
}

1a.

window.$docsify = {
      name: 'foo',
      alias: {
        '/':'/bar/',
      },
      basePath: '/foo/docs/',
      relativePath: false,
      loadSidebar: '/_sidebar.md', //explicit slash
     ...
}
window.$docsify = {
      name: 'foo',
      alias: {
        '/':'/bar/',
        '/.*/_sidebar.md': '/_sidebar.md', // alias as in docs
      },
      basePath: '/foo/docs/',
      relativePath: false,
      loadSidebar: '_sidebar.md',
     ...
}
window.$docsify = {
      name: 'foo',
      alias: {
        '/':'/bar/',
        '/foo/docs/.*/_sidebar.md': '/foo/docs/_sidebar.md', // full alias which is probably incorrect
      },
      basePath: '/foo/docs/',
      relativePath: false,
      loadSidebar: '_sidebar.md',
     ...
}

In each of these cases, I get the 404 error.

What is current behaviour

There is an 404 error message for missing sidebar for each route, even when a global sidebar is defined.

What is the expected behaviour

There should be no error message! Docsify should not look for a local sidebar file.

Other relevant information

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

  • Your OS: Windows 10 x64

  • Node.js version: 14.17.5

  • npm/yarn version: 6.14.14

  • Browser version: Version 1.33.106 Chromium: 96.0.4664.110 (Official Build) (64-bit)

  • Docsify version: 4.12.1

  • Docsify plugins: None

Please create a reproducible sandbox

Cannot do so, as I need to change how the page is served. Help appreciated.

@CxRes CxRes changed the title 404 error with a different a http server for sidebar 404 error with a different http server for sidebar files Jan 5, 2022
@kxh4892636
Copy link

kxh4892636 commented Jan 6, 2022

where is your index.html? in /foo/docs/ or /foo/
if your index.html in /foo/
Configurations blow can work

window.$docsify = {
  name: "foo",
  alias: {
    "/bar/": "/",
  },
  basePath: "/docs/",
  loadSidebar: "_sidebar.md",
  homepage: "README.md",
  ...
}

@CxRes
Copy link
Author

CxRes commented Jan 6, 2022

where is your index.html? in /foo/docs/ or /foo/ if your index.html in /foo/ Configurations blow can work

Sorry it was not clear but as I said above, files are in /oo/docs/ including index.html. The configuration works fine in that my page loads, except I get 404 error for missing sidebar for each and every route like for /foo/docs/bar/_sidebar.md or /foo/docs/baz/_sidebar.md. Docsify simply should not even be looking for these routes with loadSidebar specified as a file and exclusively look at /foo/docs/_sidebar.md for all routes. (that's why I classify this a bug)!

@kxh4892636
Copy link

kxh4892636 commented Jan 7, 2022

you can read https://docsify.js.org/#/more-pages?id=nested-sidebars.
you configure

alias: {
    "/": "/bar/",
  },

when you look at /foo/docs/_sidebar.md, you will redirect /foo/docs/bar/_sidrbar.md, so you get 404 error. So delete it and modify homePage : "/bar/README.md".
Configurations below can work

window.$docsify = {
  name: "foo",
  loadSidebar: "_sidebar.md",
  homepage: "/bar/README.md",

@trusktr
Copy link
Member

trusktr commented Jan 12, 2022

If I understand correctly, you've specified a specific sidebar, so it should not try to find side bar files based on your current path. I believe this should be improved.

@trusktr trusktr added the bug confirmed as a bug label Jan 12, 2022
@GregEisenberg
Copy link

I believe I am running into this issue too. Using c4Builder which use docsify it is generating a docsify site with sidebar. The top level pages all work perfectly. But any page in a subdirectory gets 404 for the _sidebar.md file and there is 1 request made per level of nesting. These requests are all initiated from the docsify/lib/docsify.min.js code.

Not sure if there is some setting which c4Builder needs to set when call docsify or if I am just hitting this issue.

@sy-records
Copy link
Member

Try setting alias

        alias: {
            '/.*/_sidebar.md': '/_sidebar.md'
        },

@GregEisenberg
Copy link

GregEisenberg commented Feb 17, 2022

Thanks @sy-records for your FAST reply. I was able to set
"alias": {
'/.*/_sidebar.md': '/_sidebar.md'
},
in the JSON object called window.$docsify in index.html and that does seem to solve the issue. However since I am using the c4Builder which calls docsify and generates the index.html I will have to figure out how to get this included by default.

Was I correct in adding to the window.$docsify object in index.html? Was there some other place to add it?

Thanks again!

@phoenixweiss
Copy link

@sy-records Thanks!

@QPod0
Copy link

QPod0 commented Feb 6, 2024

@sy-records Could you please take a few minutes to see why this sidebar is not loading cased by a 404 error of _sidebar.md?

I've tried both GitHub Actions and Deploy from a branch.

@sy-records
Copy link
Member

@QPod0 No GitHub Actions is required, no Jekyll theme needs to be set, just open the page, select the corresponding branch and directory.

image

@QPod0
Copy link

QPod0 commented Feb 7, 2024

Thanks @sy-records !
It now works well.

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

No branches or pull requests

7 participants