Open rajput-hemant opened 10 months ago
I managed to rewrite the path with the following vercel.json
configuration for example/simple:
{
"rewrites": [
{ "source": "/simple", "destination": "/api/simple.rs" },
{ "source": "/complex", "destination": "/api/complex.rs" },
{ "source": "/user/:id", "destination": "/api/user/[id].rs" }
],
"functions": {
"api/**/*.rs": {
"runtime": "vercel-rust@4.0.6"
}
}
}
However, this doesn't seem to work for the Experimental bundling API
. Here is my vercel.json
configuration, using the bundled_api
macro for example/route-merge:
{
"rewrites": [{ "source": "/(.*)", "destination": "/api/main.rs" }],
"functions": {
"api/main.rs": {
"runtime": "vercel-rust@4.0.6"
}
}
}
With this configuration, when I navigate to the route /foo
, i.e., without /api
as the base path, I get the usual 404: NOT_FOUND
, and when I navigate to the route /api/foo
, I get 502: BAD_GATEWAY
and see this panic log in the terminal:
❯ vc dev
Vercel CLI 32.2.0
> Ready! Available at http://localhost:3000
> Building vercel-rust@4.0.6:api/main.rs
> Built vercel-rust@4.0.6:api/main.rs [4s]
thread 'main' panicked at 'internal error: entered unreachable code', examples/route-merge/api/main.rs:8:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
TypeError: Object prototype may only be an Object or null: undefined
at Function.setPrototypeOf (<anonymous>)
at new LambdaError (/home/rajput-hemant/.bun/install/global/node_modules/vercel/dist/index.js:13136:16)
at Lambda.<anonymous> (/home/rajput-hemant/.bun/install/global/node_modules/vercel/dist/index.js:13269:27)
at Generator.next (<anonymous>)
at fulfilled (/home/rajput-hemant/.bun/install/global/node_modules/vercel/dist/index.js:13183:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Hi @rajput-hemant - thanks for raising this. From your examples it looks like we don't support both rewrites and function bundling at the same time. I'll have a look into this though 🙏
@dglsparsons Thanks for your quick response and for looking into this. I'm hopeful that this issue can be fixed, as having both rewrites and function bundling would be a valuable addition.
It appears that rewrites are not functioning as expected. Here's my
vercel.json
configuration:Additionally, when I navigate to an API route, I receive the following error when running
vc dev
: