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 {
1717 return contributorData as ContributorData
1818}
1919
20+ const PRODUCTION_ORIGIN = `https://${ process . env . VERCEL_PROJECT_PRODUCTION_URL } `
2021const ALLOWED_ORIGIN = process . env . VERCEL_URL
2122 ? `https://${ process . env . VERCEL_URL } `
2223 : "http://localhost:3000"
2324
2425export async function GET ( request : NextRequest ) {
26+ let origin = request . headers . get ( "origin" )
27+ if ( ! origin ) {
28+ origin = ( request . headers . get ( "referer" ) || "" ) . replace ( / \/ $ / , "" )
29+ }
30+
2531 const headers = new Headers ( {
2632 "Content-Type" : "application/json" ,
27- "Access-Control-Allow-Origin" : ALLOWED_ORIGIN ,
33+ "Access-Control-Allow-Origin" :
34+ origin === PRODUCTION_ORIGIN ? PRODUCTION_ORIGIN : ALLOWED_ORIGIN ,
2835 "Access-Control-Allow-Methods" : "GET" ,
2936 "Access-Control-Allow-Headers" : "Content-Type" ,
3037 "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>({
109109 if ( args . after ) params . set ( "after" , args . after )
110110 params . set ( "project" , project . name )
111111
112- const response = await fetch ( `/api/contributors?${ params . toString ( ) } ` )
112+ const response = await fetch (
113+ `/api/contributors/?${ params . toString ( ) } ` ,
114+ )
113115
114116 if ( ! response . ok ) {
115117 console . error ( `Failed to fetch contributors: ${ response . status } ` )
You can’t perform that action at this time.
0 commit comments