Skip to content

got-scraping fail with error Requested origin a does not match server a:443 (works on node.js) #18964

@kindy

Description

@kindy

What version of Bun is running?

1.2.9+9a329c04c

What platform is your computer?

Darwin 24.4.0 arm64 arm

What steps can reproduce the bug?

  • create a file fetch.ts
  • run it bun run ./fetch.ts

content of fetch.ts

import { gotScraping } from "got-scraping@4.1.1";

const res = await gotScraping("https://amazon.com");
console.log(res.statusCode, res.statusMessage, res.body);

What is the expected behavior?

show response

What do you see instead?

it fails with exit code 1, and show

13 |     stack;
14 |     response;
15 |     request;
16 |     timings;
17 |     constructor(message, error, self) {
18 |         super(message, { cause: error });
             ^
RequestError: Requested origin https://www.amazon.com does not match server https://www.amazon.com:443
   input: undefined,
 timings: {
  start: 1744428318687,
  socket: undefined,
  lookup: undefined,
  connect: undefined,
  secureConnect: undefined,
  upload: undefined,
  response: undefined,
  end: undefined,
  error: 1744428318880,
  abort: undefined,
  phases: [Object ...],
},
 options: Options {
  _unixOptions: [Object ...],
  _internals: [Object ...],
  _merging: false,
  _init: [
    [Object ...]
  ],
  merge: [Function: merge],
  request: [Getter/Setter],
  agent: [Getter/Setter],
  h2session: [Getter/Setter],
  decompress: [Getter/Setter],
  timeout: [Getter/Setter],
  prefixUrl: [Getter/Setter],
  body: [Getter/Setter],
  form: [Getter/Setter],
  json: [Getter/Setter],
  url: [Getter/Setter],
  cookieJar: [Getter/Setter],
  signal: [Getter/Setter],
  ignoreInvalidCookies: [Getter/Setter],
  searchParams: [Getter/Setter],
  searchParameters: [Getter/Setter],
  dnsLookup: [Getter/Setter],
  dnsCache: [Getter/Setter],
  context: [Getter/Setter],
  hooks: [Getter/Setter],
  followRedirect: [Getter/Setter],
  followRedirects: [Getter/Setter],
  maxRedirects: [Getter/Setter],
  cache: [Getter/Setter],
  throwHttpErrors: [Getter/Setter],
  username: [Getter/Setter],
  password: [Getter/Setter],
  http2: [Getter/Setter],
  allowGetBody: [Getter/Setter],
  headers: [Getter/Setter],
  methodRewriting: [Getter/Setter],
  dnsLookupIpVersion: [Getter/Setter],
  parseJson: [Getter/Setter],
  stringifyJson: [Getter/Setter],
  retry: [Getter/Setter],
  localAddress: [Getter/Setter],
  method: [Getter/Setter],
  createConnection: [Getter/Setter],
  cacheOptions: [Getter/Setter],
  https: [Getter/Setter],
  encoding: [Getter/Setter],
  resolveBodyOnly: [Getter/Setter],
  isStream: [Getter/Setter],
  responseType: [Getter/Setter],
  pagination: [Getter/Setter],
  auth: [Getter/Setter],
  setHost: [Getter/Setter],
  maxHeaderSize: [Getter/Setter],
  enableUnixSockets: [Getter/Setter],
  toJSON: [Function: toJSON],
  createNativeRequestOptions: [Function: createNativeRequestOptions],
  getRequestFunction: [Function: getRequestFunction],
  getFallbackRequestFunction: [Function: getFallbackRequestFunction],
  freeze: [Function: freeze],
  [Symbol(nodejs.util.inspect.custom)]: [Function],
},
    code: "ERR_GOT_REQUEST_ERROR"

      at ~/.bun/install/cache/got@14.4.7@@@1/dist/source/core/errors.js:18:9

558 | 						session[kOriginSet] = getOriginSet() || [];
559 | 
560 | 						if (session.socket.encrypted) {
561 | 							const mainOrigin = session[kOriginSet][0];
562 | 							if (mainOrigin !== normalizedOrigin) {
563 | 								const error = new Error(`Requested origin ${normalizedOrigin} does not match server ${mainOrigin}`);
                                ^
error: Requested origin https://www.amazon.com does not match server https://www.amazon.com:443
      at ~/.bun/install/cache/http2-wrapper@2.2.1@@@1/source/agent.js:563:27

Bun v1.2.9 (macOS arm64)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnode.jsCompatibility with Node.js APIsnode:http

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions