My app is working as expected on localhost but when deployed to heroku, the external page I'm parsing is returning an access denied error.
This is the response of the external page on heroku (I cannot replicate it on local setup):
2021-01-26T23:16:37.537084+00:00 app[web.1]: [
2021-01-26T23:16:37.537127+00:00 app[web.1]: '<HTML><HEAD>',
2021-01-26T23:16:37.537128+00:00 app[web.1]: '<TITLE>Access Denied</TITLE>',
2021-01-26T23:16:37.537129+00:00 app[web.1]: '</HEAD><BODY>',
2021-01-26T23:16:37.537129+00:00 app[web.1]: '<H1>Access Denied</H1>',
2021-01-26T23:16:37.537129+00:00 app[web.1]: ' ',
2021-01-26T23:16:37.537133+00:00 app[web.1]: `You don't have permission to access "http://www.pcso.gov.ph/SearchLottoResult.aspx" on this server.<P>`,
2021-01-26T23:16:37.537140+00:00 app[web.1]: 'Reference #18.89112017.1611702997.802e1a8',
2021-01-26T23:16:37.537141+00:00 app[web.1]: '</BODY>',
2021-01-26T23:16:37.537141+00:00 app[web.1]: '</HTML>',
2021-01-26T23:16:37.537141+00:00 app[web.1]: ''
2021-01-26T23:16:37.537142+00:00 app[web.1]: ]
I'm parsing the page using a callback method:
async function file_get_contents(uri, callback) {
let res = await fetch(uri, { credentials: 'include' }),
value = await res.text();
return callback ? callback(value) : value;
}
I'm using the method like this:
const pages = (url, callback) => {
file_get_contents(url)
.then(res => {
let page = res.replace(/+/gm, '').split('
')
console.log(page)
// other codes
URL is set like this:
app.get('/pages', async (req, res) => {
await pages(`https://www.pcso.gov.ph/SearchLottoResult.aspx`, (err, data) => {
if (err) {
return response.send({
err
})
}
res.send(data)
})
})
Is there a way to further debug this on heroku or replicate the issue on localhost? I'm using heroku local web
to run the app but I still cannot reproduce the issue.
question from:
https://stackoverflow.com/questions/65910915/unable-to-access-parse-external-webpage-after-deploying-to-heroku 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…