sovereignChai
04/13/2022, 10:40 PMsovereignChai
04/13/2022, 10:40 PMkian
04/13/2022, 10:41 PMconst newResponse = new Response(response.body, response);
and then modify/return newResponse
sovereignChai
04/13/2022, 10:41 PMsovereignChai
04/13/2022, 10:46 PMHardAtWork
04/14/2022, 12:58 AMjs
const myPostBody = await request.json();
KZorro
04/14/2022, 3:24 AMkian
04/14/2022, 3:25 AMkian
04/14/2022, 3:26 AMHardAtWork
04/14/2022, 4:23 AMbtc10mm
04/14/2022, 5:26 AMSkye
04/14/2022, 12:46 PMkian
04/14/2022, 12:47 PMIsaac McFadyen | YYZ01
04/14/2022, 12:47 PMIsaac McFadyen | YYZ01
04/14/2022, 12:47 PMSkye
04/14/2022, 12:50 PM[[param]].ts
pattern, and an index.ts
(which should route to the parent directory like /api/index.ts -> /api) file in the same directory, the ordering puts the param handler before the index handler, meaning your index handler will never be called, as the catch-all one is ordered first. This is applicable to both wrangler pages dev and compiling the function in production. I can see the compiled result showing the following to demonstrate this:
js
[...all previous routes here
{
routePath: "/api/:404*", // /functions/api/[[404]].ts
method: "",
middlewares: [],
modules: [onRequest]
},
{
routePath: "/api", // /functions/api/index.ts
method: "",
middlewares: [],
modules: [onRequest2]
}
]
Skye
04/14/2022, 12:52 PMSkye
04/14/2022, 12:56 PMIsaac McFadyen | YYZ01
04/14/2022, 12:59 PMRonan
04/14/2022, 2:32 PMGreg Brimble | Cloudflare Pages
04/14/2022, 3:29 PMSkye
04/14/2022, 3:32 PMGreg Brimble | Cloudflare Pages
04/14/2022, 3:35 PMSkye
04/14/2022, 3:37 PMGreg Brimble | Cloudflare Pages
04/14/2022, 3:42 PM*
is matching any number of parameters, including zero.morpheusfx
04/14/2022, 3:45 PMSkye
04/14/2022, 3:47 PMGreg Brimble | Cloudflare Pages
04/14/2022, 3:49 PM/index.ts
targeting /
) should take precedence over less explicit files (e.g. /[[path]].ts
targeting /*
)Skye
04/14/2022, 3:49 PM