Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js links aren't working when deployed on Firebase

I deployed my project on Firebase, but the links aren't working as they should be. Locally everything is working fine and paths like /account for example work, but when deployed only /account.html is working. Why is this? And can I fix this?

I first build my project with:

npm run build && npm export

Then use:

firebase deploy

to deploy.

like image 378
Lucdabomb Avatar asked Feb 13 '26 02:02

Lucdabomb


1 Answers

This is late but I had a similar problem and found the below fix worked nicely for firebase too.

Add the below to your next.config.js

module.exports =   {
  trailingSlash: true,
}

Essentially next now generates an index.html in a folder for each page and the url now ends with a /, e.g. acmecorp.com/about/

This has more detail,

(Next.js: How to make links work with exported sites when hosted on AWS Cloudfront?

like image 70
RK1 Avatar answered Feb 15 '26 16:02

RK1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!