In the migration guide you wrote that cleanUrl option is removed and it is true now by default. That means, all urls have no .html extension ending. And that is a big problem for us)
The problem, is that our documentation is deploying as a static assets to Google Cloud Storage (https://storage.googleapis.com ...). That means, clean request cannot be redirected to dirty request, and after reloading any page we have this type of error:
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>
No such object: ...
</Details>
</Error>
That happens because my-document-url is not the same object as my-document-url.html, from google's point of view.
Is it possible to override cleanUrl to false somehow in docusaurus 2?
We can't disable it, because its utilizing client side routing.
Create a redirect plugin like this
https://github.com/CanopyTax/single-spa.js.org/blob/master/website/src/plugins/docusaurus-plugin-redirects/src/index.js
Closing since its a question. Prefer discord instead
Thanks! But Im not sure I understand your advice.
I cannot create file my-document-url which could redirect to my-document-url/index.html, because of two reasons:
my-document-url directory already exists, and I cannot place file with the same namemy-document-url/index.html in the browser, docusaurus replaces the actual content, loaded from server, with Page Not Found (probably because in terms of docusaurus, route my-document-url/index.html does not exists).Aha, seems that I misunderstood you previously.
Re-reading “That happens because my-document-url is not the same object as my-document-url.html, from google's point of view.” made me understand.
Its kinda a weird behavior by google though because usually most sites fallback to html or at least index.html
Hmmm.. Is there any way to redirect in the host u are using ? Such as accessing 404 get redirected to index.html for example
That is possible, but our devops assured us that it is only available for buckets, which have cname. We are using https://storage.googleapis.com/ domain directly, so, looks like in our case it is impossible.
Pretty sure there must be a way in which
you need to set a situation such that if a user requests the URL http://www.example.com/directory, it attempts to serve the file www.example.com/directory/index.html.
I dont know much abt google storage apis but its most likely web server configuration issue (?)
On the other hand, it will be nice if we can add cleanUrl false. But its a design decision back then and its not possible atm. That would requires lot of changes in our code and is definitely not the highest priority now
Why not use zeit or netlify or even gh pages. Its a great solution too
I ran into a similar situation. I'm currently using V1 of Docusaurus and for deployment I use AWS services (S3 + CloudFront).
The problem is that when the static site assets are deployed to AWS S3 bucket, you'll have to send a request for an exact path of an object (i.e. a file). It doesn't work like a traditional web server where you're automatically redirected to "index.html".
In my case, I've setup a AWS Lambda function attached to AWS CloudFront. Before AWS CloudFront (a CDN) tries to fetch an object from AWS S3 storage, the Lambda function inspects the requested URL and changes it include "/index.html" at the end, if needed; basically tries to mimic a regular web server.
I haven't dealt with Google Cloud yet, but I believe you can do something like this using Google Cloud Function. Pretty much all the cloud providers these days provides serverless functionality.
Hope that helps.
EDIT: never mind, should've Google'd first, found what I was asking for here: https://aws.amazon.com/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/
@amimas thanks for your reply. You're mentioning a Lambda function you are using:
In my case, I've setup a AWS Lambda function attached to AWS CloudFront. Before AWS CloudFront (a CDN) tries to fetch an object from AWS S3 storage, the Lambda function inspects the requested URL and changes it include "/index.html" at the end, if needed; basically tries to mimic a regular web server.
Are you willing to share that? I have the same setup and this would solve my problem.
Thanks
@joeplaa glad you found a pointer to get started. In case it helps, you can also deploy the following directly from aws lambda. The concept is the same.
https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:621073008195:applications~standard-redirects-for-cloudfront
Most helpful comment
I ran into a similar situation. I'm currently using V1 of Docusaurus and for deployment I use AWS services (S3 + CloudFront).
The problem is that when the static site assets are deployed to AWS S3 bucket, you'll have to send a request for an exact path of an object (i.e. a file). It doesn't work like a traditional web server where you're automatically redirected to "index.html".
In my case, I've setup a AWS Lambda function attached to AWS CloudFront. Before AWS CloudFront (a CDN) tries to fetch an object from AWS S3 storage, the Lambda function inspects the requested URL and changes it include "/index.html" at the end, if needed; basically tries to mimic a regular web server.
I haven't dealt with Google Cloud yet, but I believe you can do something like this using Google Cloud Function. Pretty much all the cloud providers these days provides serverless functionality.
Hope that helps.