-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix: try to implement better ssrf-protect (#4044)
* 🐛 fix: try to implement better ssrf-protect * 🐛 fix: fix error * 💄 style: improve pwa
- Loading branch information
Showing
6 changed files
with
24 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { NextResponse } from 'next/server'; | ||
import fetch from 'node-fetch'; | ||
import { useAgent as ssrfAgent } from 'request-filtering-agent'; | ||
|
||
/** | ||
* just for a proxy | ||
*/ | ||
export const POST = async (req: Request) => { | ||
const url = await req.text(); | ||
|
||
try { | ||
const res = await fetch(url, { agent: ssrfAgent(url) }); | ||
|
||
return new Response(await res.arrayBuffer(), { headers: { ...res.headers } }); | ||
} catch (err) { | ||
console.error(err); // DNS lookup 127.0.0.1(family:4, host:127.0.0.1.nip.io) is not allowed. Because, It is private IP address. | ||
return NextResponse.json({ error: 'Not support internal host proxy' }, { status: 400 }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters