Replies: 4 comments 20 replies
-
@Blankeos what do you think? FYI @SleepyDeb |
Beta Was this translation helpful? Give feedback.
-
Official response here. |
Beta Was this translation helpful? Give feedback.
-
New package universal-autorouter-hono released 🚀 Related Hono feature request honojs/hono#3817 |
Beta Was this translation helpful? Give feedback.
-
The vite-plugin-build-routes dependency correctly bundles files from directory Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/dist/server/api/<FUNCTION>.mjs' imported from /var/task/dist/server/index.mjs
at finalizeResolution (node:internal/modules/esm/resolve:263:11)
at moduleResolve (node:internal/modules/esm/resolve:919:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1043:14)
at defaultResolve (node:internal/modules/esm/resolve:1086:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38)
at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:542:36)
at TracingChannel.tracePromise (node:diagnostics_channel:337:14) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/dist/server/api/<FUNCTION>.mjs'
} I found that the issue can be related to {
"outputDirectory": "dist/client",
+ "functions": {
+ "api/ssr.js": {
+ "includeFiles": "dist/server/api"
+ }
+ },
"rewrites": [
{
"source": "/((?!assets/).*)",
"destination": "/api/ssr.js"
}
]
} I did some try and changed the value of includeFiles (eg Source:
@brillout do you have any idea? Edit: I asked help on vercel/next.js#14807 (reply in thread) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Alternatives:
REST-as-RPC approach (recommended)
Example of
functionRetrieve
API:In
/server/api
directory, create anindex.ts
file that uses static import of api files and export them as the default export. Eg:In
/server/index.ts
, add the router handler of APIs (all APIs will have POST method):Packages
Analysis
Show Analysis
## Use case with Vite pluginRepro can be found in vite-autorouter branch.Usage (draft and outdated)
Show
Use case with Vike plugin (it's only an example and will not be implemented; see "Use case with Vite plugin")
Use case to create a Vike plugin (eg
vike-api-routes
) for API routes.Usage (draft)
Show
Related
PS: Feel free to ask anything and/or contribute.
Beta Was this translation helpful? Give feedback.
All reactions