Skip to content

Commit 779e8b0

Browse files
committed
Always return text/plain from /api/proxy
NextResponse (underlying Response) will attempt to auto detect the content type based on the passed blob. With this change the auto detection is disabled and we always return text/plain. It does not change functionality but it adds an extra safegaurd to ensure we never return HTML/JavaScript from the proxy endpoint.
1 parent 59803bb commit 779e8b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/app/api/proxy/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function GET(req: NextRequest) {
3030
const maxBytes = maxMegabytes * 1024 * 1024
3131
const fileText = await downloadFile({ url, maxBytes, timeoutInSeconds })
3232
checkIfJsonOrYaml(fileText)
33-
return new NextResponse(fileText, { status: 200 })
33+
return new NextResponse(fileText, { status: 200, headers: { "Content-Type": "text/plain" } })
3434
} catch (error) {
3535
if (error instanceof Error == false) {
3636
return makeAPIErrorResponse(500, "An unknown error occurred.")

0 commit comments

Comments
 (0)