Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/doc 150/remove vercel redirects #1300

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1242956
remove vercel redirects
fmonper1 May 9, 2023
b3b14c7
add original url
fmonper1 May 11, 2023
c2252fa
add edge middleware
fmonper1 May 15, 2023
5ed0020
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
fmonper1 May 15, 2023
ca7ecd8
disable redirect to try out edge middleware
fmonper1 May 15, 2023
7df1137
disable redirect to try out edge middleware
fmonper1 May 15, 2023
929be3a
remove catchall route
fmonper1 May 15, 2023
857bc68
remove catchall route
fmonper1 May 15, 2023
5a4d1d2
remove catchall route
fmonper1 May 15, 2023
af74c20
add log to middleware
fmonper1 May 15, 2023
5c31951
add vercel edge config
fmonper1 May 15, 2023
4c711ce
move middleware to root
fmonper1 May 15, 2023
c76b3ce
sanitixe source
fmonper1 May 15, 2023
4d59ee2
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
fmonper1 May 16, 2023
cc4b2ff
more sanitize
fmonper1 May 16, 2023
6862936
update routes
fmonper1 May 16, 2023
dfa96ce
fix middleware
fmonper1 May 16, 2023
837293a
add middleware
fmonper1 May 16, 2023
f2fad7c
remove redirect page and update matcher
fmonper1 May 16, 2023
57f0cd0
add vercel dev script
fmonper1 May 16, 2023
b6366b2
add middleware redirect for one url
fmonper1 May 17, 2023
2edab84
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
fmonper1 May 17, 2023
857055f
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
fmonper1 May 25, 2023
0d28c7a
Merge branch 'chore/DOC-150/remove-vercel-redirects' of github.com:sm…
fmonper1 May 25, 2023
a246144
enable redirects for all
fmonper1 May 25, 2023
ac62e11
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
dwightjl May 26, 2023
00ccde9
Merge branch 'main' into chore/DOC-150/remove-vercel-redirects
fmonper1 Jul 21, 2023
c263ac6
Merge remote-tracking branch 'origin/main' into chore/DOC-150/remove-…
dwightjl Jul 27, 2023
0a9b363
Update all packages including hardhat
dwightjl Jul 27, 2023
22d4336
Force node 18
dwightjl Jul 27, 2023
1ede339
Merge remote-tracking branch 'origin/main' into chore/DOC-150/remove-…
dwightjl Jul 29, 2023
532952a
Package updates
dwightjl Jul 29, 2023
78fa630
Add GitHub dependency caching and rebuild package-lock.json
dwightjl Jul 29, 2023
a8f1942
Switch steps order
dwightjl Jul 29, 2023
a21b8dd
Revert unnecessary changes
dwightjl Jul 29, 2023
0f8d6c3
Merge remote-tracking branch 'origin/main' into chore/DOC-150/remove-…
dwightjl Aug 3, 2023
10f8205
Refresh package-lock.json
dwightjl Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ typechain-types/
.tmp

.cache
.vercel
24 changes: 24 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import redirectsFile from "./src/features/redirects/redirects.json"

export const config = {
matcher: "/((?!api|static|.*\\..*|_astro|src).*)",
}

const { redirects } = redirectsFile

export default function middleware(request: Request) {
const url = new URL(request.url)
const pathname = url.pathname
const referrer = request.headers.get("referer")

const redirect = redirects.find((entry) => entry.source === pathname)

if (redirect) {
const finalUrl = new URL(request.url)
finalUrl.pathname = redirect.destination
if (referrer) {
finalUrl.searchParams.append("referrer", referrer)
}
return Response.redirect(finalUrl)
}
}
16,798 changes: 14,328 additions & 2,470 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "astro dev",
"dev:vercel": "vercel dev",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this allows us to test the middleware locally without deploying to vercel

"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
Expand Down Expand Up @@ -32,6 +33,7 @@
"@metamask/detect-provider": "^2.0.0",
"@metamask/providers": "^10.2.1",
"@nanostores/preact": "^0.4.1",
"@vercel/edge": "^0.3.4",
"astro-embed": "^0.2.1",
"clipboard": "^2.0.11",
"ethers": "^5.7.2",
Expand Down Expand Up @@ -77,7 +79,8 @@
"solhint": "^3.4.1",
"solhint-plugin-prettier": "^0.0.5",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"vercel": "^29.3.0"
},
"lint-staged": {
"*.{css,md,mdx,yml,yaml,astro}": "prettier --write",
Expand Down
Loading