#Deploying NextJS to Google CDN

2 messages · Page 1 of 1 (latest)

regal sedge
#

I'm having a funk issue setting up NextJS on Google CDN.

Setup:
Cloud armor sites in front of a load balancer which is connected to a Google Storage bucket, and the DNS has been configured to point to correct IP. (Sidenote currently, access is restricted to known IPs).

As it is being delivered via a CDN, i have the assetPrefix set in next.config.js to the domain and have MainPageSuffix configured to index.html. I have ran npm run build && npm run exportwhich created an out folder. I have uploaded the contents of this folder into the storage bucket and it works 99% as expected.

The one glitch I have is that whilst I can browse and interact with additional pages in the website as expected from \ entrey point, if I hit any of the pages directly, I get a NoSuchKey XML error message, however if if hit the route.html direct it works as expected e.g. enter via www.example.com/ and click on about page the page www.example.com/about displays as expected, however if I go to www.example.com/about direct I get the NoSuchKey error, however if I go to www.example.com/about.html it works as expected.

I'm confused as to why this is happening.

Is it a configuration is in the storage bucket/load balancer or am I missing something in my NextJS config somewhere ie. next.config.js or do I need to configure routes somewhere?

regal sedge
#

Having searched online all the tutorials are suggesting that running on Cloud Run is an approach..but that's not suitable for my Use Case.