mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Keep redirect lookups from crashing SSR pages
Dynamic Astro routes were reading Netlify redirect config through a cwd-relative path, which is fragile inside a serverless runtime and was taking detail pages down with 500s before render. Resolve netlify.toml by searching from the module directory and current working directory, and fail open in request-time redirect lookup so a config read problem does not block page rendering. Constraint: Netlify serverless cwd is not guaranteed to be the repo root Rejected: Inline redirects into route modules | would duplicate platform config and drift from source of truth Rejected: Leave redirect lookup hard-failing | one config read failure should not take down unrelated pages Confidence: medium Scope-risk: narrow Reversibility: clean Directive: Keep redirect config lookup independent of process cwd anywhere server code reads deploy config files Tested: vitest ./test/prebuild/config-node.test.js; pnpm run netlify-build Not-tested: live Netlify production deploy before push
This commit is contained in:
parent
d026a5420b
commit
820e495d2d
3 changed files with 85 additions and 3 deletions
|
|
@ -56,7 +56,13 @@ export async function applyResponseDefaults ( Astro ) {
|
|||
export async function catchRedirectResponse ( Astro ) {
|
||||
const requestUrl = new URL( Astro.request.url )
|
||||
|
||||
const netlifyRedirectUrl = await getNetlifyRedirect( requestUrl.pathname )
|
||||
let netlifyRedirectUrl = null
|
||||
|
||||
try {
|
||||
netlifyRedirectUrl = await getNetlifyRedirect( requestUrl.pathname )
|
||||
} catch ( error ) {
|
||||
console.warn( `Skipping redirect lookup for ${ requestUrl.pathname }`, error )
|
||||
}
|
||||
|
||||
// console.log('netlifyRedirectUrl', netlifyRedirectUrl)
|
||||
|
||||
|
|
@ -67,4 +73,3 @@ export async function catchRedirectResponse ( Astro ) {
|
|||
return null
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue