Im trying to access an endpoint in next.js from a headless cms proxy in node.js and i cant get it to work. I want to redirect me to a site but instead i get the following error:
For help, see: https://nodejs.org/en/docs/inspector (node:8549) UnhandledPromiseRejectionWarning: Error: Request failed with status code 500 at createError (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/core/createError.js:16:15) at settle (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/adapters/http.js:236:11) at IncomingMessage.emit (events.js:322:22) at endReadableNT (_stream_readable.js:1187:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) (node:8549) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:8549) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:8549) UnhandledPromiseRejectionWarning: Error: Request failed with status code 500 at createError (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/core/createError.js:16:15) at settle (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/home/george/Documents/Coding/NodeJs/node-server/node_modules/axios/lib/adapters/http.js:236:11) at IncomingMessage.emit (events.js:322:22) at endReadableNT (_stream_readable.js:1187:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) (node:8549) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
Proxy localhost:4000
app.get("/test", (req, r, next) => {
Axios.get('http://localhost:3000/api/hello').then((res)=>{
})
});
Next.js endpoint hello.js localhost:3000
export default (req, res) => {
res.statusCode = 200;
res.redirect('https://youtube.com');
};