I've deployed my Node.js Koa API app on Heroku. I'm making a call to a USAJOB.gov API and it works on my localhost. However, on Heroku I get this error:
You don't have permission to access "http://data.usajobs.gov/$(SERVE_403)/api/search?" on this server.
Here is my Koa router snippet:
router.get('/jobs', async (ctx) => {
const { keyword, location } = ctx.query;
const url = `https://data.usajobs.gov/api/search?
Keyword=${keyword}&LocationName=${location}`;
const host = 'data.usajobs.gov';
const userAgent = '<redacted>';
const authKey = '<redacted>';
const headers = {
Host: host,
'User-Agent': userAgent,
'Authorization-Key': authKey,
};
await fetch(url, {
headers,
method: 'GET',
});
}