Hivekind / hivekind.com

0 stars 0 forks source link

remove /work page, and handle redirect properly (without build warning) #133

Closed shuwnyuantee closed 3 weeks ago

shuwnyuantee commented 3 weeks ago

We still have one last build warning:

 ⚠ Specified "redirects" will not automatically work with "output: export". See more info here: https://nextjs.org/docs/messages/export-no-custom-routes

This is related to how we redirect the /work page. Apparently, that redirect approach only works on Next.js apps with server-side rendering.

Also, the /work page is still available in our repo.

Issues remaining:

shuwnyuantee commented 3 weeks ago

The warning indicates that you have defined redirects in your next.config.js, but since you're exporting a static site, these redirects cannot be handled by Next.js at runtime because there's no server to process them.

What the Warning Means

Static Export Limitation: When you set output: 'export' in your next.config.js, Next.js generates a completely static version of your site. This means all pages are pre-rendered to static HTML files without any server-side capabilities.

Custom Redirects Not Supported: Features like custom redirects, rewrites, and headers rely on server-side logic to function. Since a static export doesn't include a server to process these rules, they won't work out of the box.

shuwnyuantee commented 3 weeks ago

Apparently this is a workaround for localhost, as confirmed by @parasquid For production build, accessing /work is redirected correctly to home page.

Will close this ticket without fix.

parasquid commented 3 weeks ago

Yup! That's because we're exporting to static files, so that means the responsibility for redirects happen on the application serving the html static files.

Usually that would be apache or nginx, but in our case since we're deploying to netlify we need to somehow inform netlify about the redirect that we want. This is done through the netlify.toml file https://github.com/Hivekind/hivekind.com/blob/main/netlify.toml which then does the redirect.

We didn't do this for cloudflare since that's just staging, but let me know if you would like to also get that working (it's not that difficult, https://developers.cloudflare.com/pages/configuration/redirects/ has the instructions).