Nuxt Hybrid SSR _headers/_redirects not working
We recently switched from a full Static website to a hybrid Nuxt delivery. While the routing and delivery are working as expected, it seems when we switched the _headers and _redirects files stopped working. I have uploaded the redirects to a bulk redirect for now, but would like to know if there's something I can do to restore the functionality we had before. Is this a limitation of Hybrid delivery? It seems the rules are getting read in, but for some reason aren't triggering.
As an example:
Header rules:
https://qa.rhone.com/
X-Robots-Tag: noindex, nofollow
https://qa.rhone.com/*
X-Robots-Tag: noindex, nofollow
Redirect rule:
/fighter /?discount=fighter 301
https://qa.rhone.com/fighter not redirecting
Logs from the build:
14:29:55.001 Deploying your site to Cloudflare's global network...
14:29:57.697 Parsed 761 valid redirect rules.
14:29:57.697 Parsed 19 valid header rules.
2 Replies
Are you not seeing this apply to all requests or just some?
_headers and _redirects won't apply when there's a Worker (Function) handling the response (so doing that server-side functionality)
I'd expect Nuxt to still have static assets run through Pages as normal though
It seems to be all requests that I can tell.
This is a redirect that should be statically delivered and isn't triggering the redirect
/collections/view-all-tops/ /collections/mens-view-all-tops/ 301
This is a page that should also be static and isn't getting robots applied
https://qa.rhone.com/pages/men/
routeRules: {
'/': {
ssr: true
},
'/collections/**': {
prerender: true
},
'/pages/**': {
prerender: true
}
},
I had read the note about functions handling the requests not triggering these rules, but I wasn't sure what was going on behind the scenes with the updated delivery mode, as it's spooled up behind the scenes from what I can tell. Is there a reccommended alternative to handling the redirects? I have them in a bulk redirect for now but it would be nice to have them updated at build time as we were pulling them out of our CMS.
Looking at the functions tab on the pages deployment, I am seeing a change in the Invocation routes here:
With Static build:
{
"version": 1,
"description": "Catch-all rule generated by Pages CI",
"include": [
"/*"
],
"exclude": []
}
Current Hybrid build:
{
"version": 1,
"include": [
"/*"
],
"exclude": [
"/_nuxt/*",
"/_headers",
"/_redirects",
"/cart.js",
"/check-solid.svg",
"/dnosgibt.js",
"/email-referrer-head-check.js",
"/favicon.png",
"/favicon.svg",
"/icon.png",
"/loaderWorker.js",
"/nacelle-horizontal-dark.svg",
"/nacelle-logo.svg",
"/robots.txt",
"/service-worker.js",
...
There are also several "/collections/..." routes included here (80), but not all of the routes we have on site (hundreds).
Looks like there are some Nuxt apps that I'll look at for now to handle these more natively, but it was nice to have these a little closer to the request.