Download next.js/test/integration/api-support/pages/api/proxy-self.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 490 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/integration/api-support/pages/api/proxy-self.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/integration/api-support/pages/api/proxy-self.js
-
curl -L -o proxy-self.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/integration/api-support/pages/api/proxy-self.js
490 Bytes
| import httpProxy from 'http-proxy' | |
| export default async function handler(req, res) { | |
| const port = req.headers.host.split(':').pop() | |
| const proxy = httpProxy.createProxy({ | |
| target: `http://127.0.0.1:${port}/${ | |
| req.query.buildId | |
| ? `_next/static/${req.query.buildId}/_ssgManifest.js` | |
| : `user` | |
| }`, | |
| ignorePath: true, | |
| }) | |
| await new Promise((resolve, reject) => { | |
| proxy.on('error', reject) | |
| proxy.on('close', resolve) | |
| proxy.web(req, res) | |
| }) | |
| } | |