0
// next js - [...api]

import httpProxy from "http-proxy";
const BLOG_SERVER = process.env.BLOG_SERVER; // https://example.com
export const config = {
  api: {
    bodyParser: false,
  },
}

export default async function Api(req, res) {
    const proxy = httpProxy.createProxyServer();
    proxy.web(req, res, {
      target: BLOG_SERVER
    });
    proxy.on('error', function (e) {
        console.log(e)
    });
}

The BLOG_SERVER has been hosted at heroku and next.js website has been hosted at vercel.

When i looked at the next.js server logs, then the following are printed.

vercel-logs

How can i solve this??

Rahul
  • 1,858
  • 1
  • 12
  • 33
  • Does this answer your question? [NodeJS Express reverse proxy TLS\_CERT\_ALTNAME\_INVALID error](https://stackoverflow.com/questions/57766108/nodejs-express-reverse-proxy-tls-cert-altname-invalid-error) – juliomalves Aug 14 '21 at 14:21
  • No, now i am getting this error ```js [POST] /api/do/auth/sign-up 19:57:38:74 Function Status: None Edge Status: 504 Duration: 10010.54 ms Init Duration: N/A Memory Used: 32 MB ID: hd5x2-1628951258206-6d7a91672cec User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 { msg: 'Got the request...' } 2021-08-14T14:27:48.881Z b242cc90-828c-4368-82fd-475ef4db2d98 Task timed out after 10.01 seconds ``` – Rahul Aug 14 '21 at 14:29

0 Answers0