thuliteio / doks

Everything you need to build a stellar documentation website. Fast, accessible, and easy to use.
https://getdoks.org
MIT License
2.12k stars 361 forks source link

FlexSearch is broken when baseUrl contains URI with path #1275

Open sivanov-nuodb opened 3 months ago

sivanov-nuodb commented 3 months ago

Description

FlexSearch is broken when the baseUrl contains a path in the URI (e.g. http://localhost:8080/nuodb-cp-docs/). The search-index.json is still requested from the incorrect base path.

Steps to reproduce

1 . Build the site

rm -rf public tmp/public
npm run build -- --baseURL http://localhost:8080/nuodb-cp-docs/
  1. Serve the generated site
cp public tmp/nuodb-cp-docs
cd tmp && http-server

Navigate to http://localhost:8080/nuodb-cp-docs/ in the browser and try to search. The below log shows the 404 errors preventing search from working.

[Mon Aug 19 2024 18:07:31 GMT+0300 (Eastern European Summer Time)]  "GET /search-index.json" Error (404): "Not found"
[Mon Aug 19 2024 18:07:31 GMT+0300 (Eastern European Summer Time)]  "GET /favicon-192x192.png" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
[Mon Aug 19 2024 18:07:31 GMT+0300 (Eastern European Summer Time)]  "GET /favicon-192x192.png" Error (404): "Not found"

Expected result

I'm expecting to see GET /nuodb-cp-docs/search-index.json.

Actual result

Search is broken and 404 error is returned.

Environment

$ hugo version
hugo v0.132.1+extended darwin/amd64 BuildDate=2024-08-13T10:10:10Z VendorInfo=brew
$ npm version
{
  'nuodb-cp-docs': '0.0.1',
  npm: '10.8.2',
  node: '22.6.0',
  acorn: '8.11.3',
  ada: '2.9.0',
  amaro: '0.0.6',
  ares: '1.32.3',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '45.0',
  icu: '75.1',
  llhttp: '9.2.1',
  modules: '127',
  napi: '9',
  nbytes: '0.1.0',
  ncrypto: '0.0.1',
  nghttp2: '1.62.1',
  nghttp3: '0.7.0',
  ngtcp2: '1.3.0',
  openssl: '3.0.13+quic',
  simdjson: '3.9.4',
  simdutf: '5.3.0',
  sqlite: '3.46.0',
  tz: '2024a',
  undici: '6.19.2',
  unicode: '15.1',
  uv: '1.48.0',
  uvwasi: '0.0.21',
  v8: '12.4.254.21-node.18',
  zlib: '1.3.0.1-motley-209717d'
}
  "dependencies": {
    "@hyas/doks-core": "^1.6.1",
    "@hyas/images": "^3.2.0",
    "@hyas/inline-svg": "^1.1.0",
    "@hyas/seo": "^2.3.0",
    "@tabler/icons": "^3.2.0",
    "gethyas": "^2.4.2"
  },
h-enk commented 3 months ago

Duplicate of https://github.com/thuliteio/doks-core/issues/91

To be fixed — solution: https://github.com/thuliteio/doks/discussions/1207#discussioncomment-9521322

PR on thuliteio/doks-core is welcome 😉