File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
components/index-page/how-it-works Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,21 @@ function getContributorData(): ContributorData {
17
17
return contributorData as ContributorData
18
18
}
19
19
20
+ const PRODUCTION_ORIGIN = `https://${ process . env . VERCEL_PROJECT_PRODUCTION_URL } `
20
21
const ALLOWED_ORIGIN = process . env . VERCEL_URL
21
22
? `https://${ process . env . VERCEL_URL } `
22
23
: "http://localhost:3000"
23
24
24
25
export async function GET ( request : NextRequest ) {
26
+ let origin = request . headers . get ( "origin" )
27
+ if ( ! origin ) {
28
+ origin = ( request . headers . get ( "referer" ) || "" ) . replace ( / \/ $ / , "" )
29
+ }
30
+
25
31
const headers = new Headers ( {
26
32
"Content-Type" : "application/json" ,
27
- "Access-Control-Allow-Origin" : ALLOWED_ORIGIN ,
33
+ "Access-Control-Allow-Origin" :
34
+ origin === PRODUCTION_ORIGIN ? PRODUCTION_ORIGIN : ALLOWED_ORIGIN ,
28
35
"Access-Control-Allow-Methods" : "GET" ,
29
36
"Access-Control-Allow-Headers" : "Content-Type" ,
30
37
"Cache-Control" : "public, s-maxage=86400, stale-while-revalidate=172800" ,
Original file line number Diff line number Diff line change @@ -109,7 +109,9 @@ const ProjectType = new GraphQLObjectType<Project>({
109
109
if ( args . after ) params . set ( "after" , args . after )
110
110
params . set ( "project" , project . name )
111
111
112
- const response = await fetch ( `/api/contributors?${ params . toString ( ) } ` )
112
+ const response = await fetch (
113
+ `/api/contributors/?${ params . toString ( ) } ` ,
114
+ )
113
115
114
116
if ( ! response . ok ) {
115
117
console . error ( `Failed to fetch contributors: ${ response . status } ` )
You can’t perform that action at this time.
0 commit comments