docusaurus: Error on development when changing baseUrl
Is this a bug report?
Yes
Have you read the Contributing Guidelines on issues?
Yes
Environment
Node: 8.9.1 Docusaurus: 1.1.1
(Docusaurus version via npm outdated docusaurus
or yarn outdated docusaurus
, OS, Node, npm, yarn)
Steps to Reproduce
I followed the step on setting your landing page: Docs landing Page. Which works well. However, the problem is when you change your baseUrl
for deployment:
const siteConfig = {
title: '<Project title>' /* title for your website */,
tagline: '<Project tagline>',
url: 'https://<org>.github.io' /* your website url */,
baseUrl: '/<project>/' /* base url for your project */,
// For github.io type URLs, you would set the url and baseUrl like:
// url: 'https://facebook.github.io',
// baseUrl: '/test-site/',
It works on build, but when I try to yarn start
it gives me an error:
If I put back the baseUrl: '/'
it will work.
Workaround: make baseUrl: '/'
when updating the doc and put back the baseUrl: '/project/'
url when done.
Expected Behavior
It should redirect to my doc
page as expected without switching baseUrl
for development and production
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (10 by maintainers)
hi @joshuaalpuerto, did you manage to resolve the issue ? Sorry for the delayed response. I just got the chance to look on this.
When you change your
baseUrl
to/project1/
, this means that instead oflocalhost:3000
, you should be able to access it atlocalhost:3000/project1
Alright @joshuaalpuerto . I’m closing this issue for now as it seems it’s been working for you. Feel free to submit a PR on the improved redirect when you have the time.
@joshuaalpuerto I don’t own this repo but I believe that this repo is
PR Friendly
👍 Feel free to submit one. No PR is too small if it’s useful.I can give some advice though, that changes in your code might introduce a bug. What if my req.path is
baseUrl/xxxx
? will it becomebaseUrl/baseUrl/xxx
? . Try testing the changes on Docusaurus with many test cases 😃Thanks! Im actually checking the
server.js
now. Then I’ll get back once I figure this out. 😄If you think improvement can be done & want to contribute, Feel free to submit a PR for it 😄 .
Adding this for your reference on where to modify https://github.com/facebook/Docusaurus/blob/b7be85843af2a07ead183dd8a467ebcf83e9a3e3/lib/server/server.js#L530-L533
@endiliey the code works
siteConfig.js
Then you have to change the redirect code from HTML as per docs:
From:
To:
I will try this later and let you know! Thanks for your help!
I’m not the official maintainer of this repo, but that might be a good idea. It’s quite simple as well.
Quick implementation:
instead of
https://github.com/facebook/Docusaurus/blob/b7be85843af2a07ead183dd8a467ebcf83e9a3e3/lib/start-server.js#L66