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

s3 routes error #34

Open
leon-dunamu opened this issue Sep 30, 2021 · 1 comment
Open

s3 routes error #34

leon-dunamu opened this issue Sep 30, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@leon-dunamu
Copy link
Collaborator

I'm deploying a next.js app as a static export, to an s3 bucket configured for static website hosting.

I use next's build and export commands to generate the out/ directory and then copy that into my s3 bucket

The bucket then contains some files, for simplicity lets say there's just index.html and about.html

The problem is when a user hits index.html via www.website.com then navigates to www.website.com/about everything works, but reloading www.website.com/about fails of course.

www.website.com/about.html finds the correct asset to render the site however

Is there a way to export a static next.js app, host on s3, and have requests to /about proxy /about.html ?

As always, thanks for looking, and thanks even more for participating.

@leon-dunamu leon-dunamu self-assigned this Sep 30, 2021
@leon-dunamu
Copy link
Collaborator Author

Maybe ...

On your next.config.js file at the root of the project.

module.exports = {
    trailingSlash: true,
}

Now you can create your pages (e.g. about.jsx) inside the pages directory and Next will create a folder with the file name with an index.html file inside of it when you run the export command.

Give it a try, worked fine here.

@leon-dunamu leon-dunamu added the bug Something isn't working label Sep 30, 2021
leon-dunamu added a commit that referenced this issue Sep 30, 2021
leon-dunamu added a commit that referenced this issue Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant