So, i'm doing an api, to query a certain map service which require an API key. I want to keep the API key private so in my own api on the server, I will call a http.request to the map service, then immediately pipe it into the response to my own api user.
Here is sample code to illustrate the idea:
import http from "http";
export default function handler(req, res) {
http.request(`http://map.service.example.com/foo-bar`, (mapRes) => mapRes.pipe(res));
}
But so far, the code above doesn't work.
Any other possible way (with fetch maybe?) is welcome.