@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from "next/server"
2
2
import contributorData from "../../../../scripts/sync-landing-schema/data.json"
3
3
4
4
export const dynamic = "auto"
5
+ export const revalidate = 172800
5
6
6
7
interface Contributor {
7
8
id : string
@@ -17,31 +18,20 @@ function getContributorData(): ContributorData {
17
18
return contributorData as ContributorData
18
19
}
19
20
20
- const PRODUCTION_ORIGIN = `https://${ process . env . VERCEL_PROJECT_PRODUCTION_URL } `
21
- const ALLOWED_ORIGIN = process . env . VERCEL_URL
22
- ? `https://${ process . env . VERCEL_URL } `
23
- : "http://localhost:3000"
24
-
25
- function isSameOrigin ( origin : string , allowedOrigin : string ) : boolean {
26
- return (
27
- origin . replace ( / \/ \/ w w w \. / , "" ) === allowedOrigin . replace ( / \/ \/ w w w \. / , "" )
28
- )
29
- }
21
+ const ALLOWED_ORIGIN =
22
+ process . env . VERCEL_ENV === "production"
23
+ ? `https://${ process . env . VERCEL_PROJECT_PRODUCTION_URL } `
24
+ : process . env . VERCEL_URL
25
+ ? `https://${ process . env . VERCEL_URL } `
26
+ : "http://localhost:3000"
30
27
31
28
export async function GET ( request : NextRequest ) {
32
- let origin = request . headers . get ( "origin" )
33
- if ( ! origin ) {
34
- origin = ( request . headers . get ( "referer" ) || "" ) . replace ( / \/ $ / , "" )
35
- }
36
-
37
29
const headers = new Headers ( {
38
30
"Content-Type" : "application/json" ,
39
- "Access-Control-Allow-Origin" : isSameOrigin ( origin , PRODUCTION_ORIGIN )
40
- ? PRODUCTION_ORIGIN
41
- : ALLOWED_ORIGIN ,
31
+ "Access-Control-Allow-Origin" : ALLOWED_ORIGIN ,
42
32
"Access-Control-Allow-Methods" : "GET" ,
43
33
"Access-Control-Allow-Headers" : "Content-Type" ,
44
- "Cache-Control" : " public, s-maxage=86400, stale-while-revalidate=172800" ,
34
+ "Cache-Control" : ` public, s-maxage=86400, stale-while-revalidate=${ revalidate } ` ,
45
35
} )
46
36
47
37
try {
0 commit comments