We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcf1db4 commit 76d401bCopy full SHA for 76d401b
src/middleware/index.ts
@@ -0,0 +1,18 @@
1
+import { defineMiddleware } from "astro:middleware";
2
+
3
+// `astro dev` only middleware so that `/api/...` links can be viewed.
4
+export const onRequest = defineMiddleware(async (context, next) => {
5
+ if (import.meta.env.DEV) {
6
+ if (context.url.pathname.startsWith("/api/")) {
7
+ const url = new URL(context.url.pathname, import.meta.env.SITE);
8
9
+ return fetch(url, {
10
+ headers: {
11
+ "accept-encoding": "identity",
12
+ },
13
+ });
14
+ }
15
16
17
+ return next();
18
+});
0 commit comments