Skip to content

404 pages don't work when a site has Functions but no SSR/DSG pages #330

Closed
@moneal

Description

@moneal

Deploying a Gatsby 4 site with functions defined in the api folder breaks 404 handling in production.

If trying to access a non-existent page like /404-test triggers the below error:

{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '/var/task/.cache/page-ssr'\nRequire stack:\n- /var/task/.netlify/functions-internal/__dsg/__dsg.js\n- /var/task/__dsg.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Runtime.ImportModuleError: Error: Cannot find module '/var/task/.cache/page-ssr'","Require stack:","- /var/task/.netlify/functions-internal/__dsg/__dsg.js","- /var/task/__dsg.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js","    at _loadUserApp (/var/runtime/UserFunction.js:202:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}

If you rename the gatsby api folder to _api and redeploy 404 pages start working correctly.

gatsby-plugin-netlify version 4.1 is installed and enabled.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions