mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-04 23:43:51 +08:00
web: add function to redirect Grind 75 path
This commit is contained in:
5
apps/website/.gitignore
vendored
5
apps/website/.gitignore
vendored
@ -17,4 +17,7 @@
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
yarn-error.log*
|
||||
|
||||
# cloudflare
|
||||
.wrangler
|
||||
|
13
apps/website/functions/grind75/[[catchall]].js
Normal file
13
apps/website/functions/grind75/[[catchall]].js
Normal file
@ -0,0 +1,13 @@
|
||||
const SOURCE_HOST = 'https://grind75.vercel.app';
|
||||
|
||||
export async function onRequest(context) {
|
||||
const { request } = context;
|
||||
// Define the original and target paths
|
||||
const url = new URL(request.url);
|
||||
|
||||
// Rewrite to the new domain, preserving the original path and query string
|
||||
const newURL = SOURCE_HOST + url.pathname + url.search;
|
||||
|
||||
// Fetch the content from the new domain
|
||||
return await fetch(newURL, request);
|
||||
}
|
Reference in New Issue
Block a user