Skip to content

Commit

Permalink
Add rewrites via middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
brachkow committed May 9, 2024
1 parent 89de81d commit 011bc64
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export async function onRequest(context) {
const { request, next } = context;
const res = await next();
const { pathname } = new URL(request.url);

if (pathname.startsWith('/api/')) {
return new Response.redirect(
'https://app.tough-dev.school' + pathname,
'200',
);
}

return res;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
},
"devDependencies": {
"@babel/core": "^7.23.2",
"@cloudflare/workers-types": "^4.20240502.0",
"@faker-js/faker": "^8.2.0",
"@pinia/testing": "^0.1.3",
"@rushstack/eslint-patch": "^1.5.1",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 011bc64

Please sign in to comment.