Astro framework + SSR. Netlify config headers and redirects aren't applied

I have an Astro website, and I’m struggling to properly deploy in SSR mode.

Using Netlify CLI netlify dev, SSR routes work, redirects and headers apply, except Content-Security-Policy if present in netlify.toml, the server crashes and throws an error:

Netlify configuration redirects, headers only work on static (pre-rendered) routes, such as /static/ route for example.

Also, the custom /404 page does not handle not found routes in SSR, instead showing a blank page with the text “Not Found” (if you remove this page, Netlify uses its own default version). In main project most of the routes don’t work, I guess it’s because of using urql as the fetch library.

.env:

AWS_LAMBDA_JS_RUNTIME=nodejs16.x
NODE_VERSION=16.19.0

stackblitz: Predaytor - Astro Ssr Netlify - StackBlitz

deploy (using trailing slash):
https://luxury-capybara-511d8e.netlify.app/

Not in this example, but in the main project, here are the logs during build and deployment. (about why most of the routes does not work, using the fetch library unlike this example).

Hi @predaytor :wave:t6: ,

Welcome to the forums! Sorry to hear you are having issues with your build. Can you please give this resource a read and see if it helps solve your [problem?] [Support Guide] Compiled Build and Deploy Resources -- start here!? It is a compilation of all of our build and deploy resources. This is a good starting point.

Lastly, please share these additional details so we can look into your experience further:

  • repository
  • what steps you have taken to resolve this issue
  • any error messages you have received in your terminal window or in the developer console
  • confirm if you got it working locally first
1 Like