sourcemaps.io icon indicating copy to clipboard operation
sourcemaps.io copied to clipboard

`request` library throws 403 because user-agent is missing (e.g., cloudfront url with s3 object)

Open tmikeschu opened this issue 1 year ago • 1 comments

Environment

What version are you running? Etc.

Steps to Reproduce

Example bundle to validate: https://app-static-prod.posthog.com/static/index-ZPBKKMYQ.js

https://sourcemaps.io/report/1727455456490_https%3A%2F%2Fapp-static-prod.posthog.com%2Fstatic%2Findex-ZPBKKMYQ.js

  1. fetch(url) is a 200
  2. request(url) is a 403
  3. request(url, { headers: { 'User-Agent': 'foo' } }) is a 200

Expected Result

Sourcemap should be valid (I can visit both the bundle and the referenced sourceMappingURL in a browser.

Actual Result

Image

I have run these urls using request myself to see that the response code is 403.

Since request is deprecated, maybe use a more modern fetch mechanism? Or just add a user agent header.

tmikeschu avatar Sep 27 '24 16:09 tmikeschu

Also running into this issue. I have cloudflare rules to block requests that have either a missing user-agent header or a blank one. I'd prefer to leave that rule in place

jer-tx avatar May 02 '25 01:05 jer-tx