File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -83,14 +83,16 @@ export async function POST(req: Request) {
83
83
} else {
84
84
score = "58" ;
85
85
}
86
-
86
+ // Extract the host and protocol from the incoming request
87
+ const url = new URL ( req . url ) ;
88
+ const baseUrl = `${ url . protocol } //${ url . host } ` ;
87
89
console . log (
88
90
"ABOUT TO SEND RESULT " ,
89
91
score ,
90
92
"to" ,
91
- "https://" + process . env . VERCEL_URL + ` /api/feedback/result`
93
+ ` ${ baseUrl } /api/feedback/result`
92
94
) ;
93
- axios . post ( "https://" + process . env . VERCEL_URL + ` /api/feedback/result`, {
95
+ axios . post ( ` ${ baseUrl } /api/feedback/result`, {
94
96
score,
95
97
challenge,
96
98
code,
Original file line number Diff line number Diff line change @@ -76,18 +76,14 @@ export async function POST(req: Request) {
76
76
lastSubmission : new Date ( ) . toISOString ( ) ,
77
77
} ) ;
78
78
}
79
-
80
- console . log ( "BASE URL: " , "https://" + process . env . VERCEL_URL ) ;
79
+ // Extract the host and protocol from the incoming request
80
+ const url = new URL ( req . url ) ;
81
+ const baseUrl = `${ url . protocol } //${ url . host } ` ;
82
+ console . log ( "BASE URL: " , baseUrl ) ;
81
83
// Use the base URL for Axios requests
82
- axios . put (
83
- "https://" + process . env . VERCEL_URL + `/api/increment/submit` ,
84
- { }
85
- ) ;
84
+ axios . put ( `${ baseUrl } /api/increment/submit` , { } ) ;
86
85
87
- axios . post (
88
- "https://" + process . env . VERCEL_URL + `/api/code/score` ,
89
- body
90
- ) ;
86
+ axios . post ( `${ baseUrl } /api/code/score` , body ) ;
91
87
92
88
return NextResponse . json ( { message : "Accepted" } , { status : 202 } ) ;
93
89
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments