question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gives error "Only absolute URLs are supported" even though the URL is absolute

See original GitHub issue

I did

require('node-fetch')('http://localhost:3000/')

and it gave me an error: TypeError: Only absolute URLs are supported

Reproduction

Steps to reproduce the behavior:

  1. Get node version 15.2.1
  2. run npm install node-fetch@2.6.1
  3. run node -p "require('node-fetch')('http://localhost:3000/')"

Expected behavior

I expected it to run fine without any errors and return the response. https://www.npmjs.com/package/node-fetch#fetchurl-options

Your Environment

software version
node-fetch 2.6.1
node 15.2.1
npm 6.14.8
Operating System Windows 10 v2004 build 19041.630

Additional context

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:14
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
tbrannamcommented, Feb 2, 2021

I have had a similar issue, and the problem was multiple versions of node-fetch. In my case I was running in a monorepo and the test app and the support packages resolved to different node_modules folder. Somewhere deep in the implementation there is a check against a JS symbol which would not match in this case.

1reaction
pavellozcommented, Oct 28, 2021

I have the same issue (for a long time, i just didnt write about it) when trying to build project with routify which depends on node-fetch. Whats weird, it works when i start i dev mode (and thats how i work around the issue… i just dont build, i leave project in dev mode forever).

It looks like a lot of people are waiting for it to be resolved: https://github.com/mailgun/mailgun-js/issues/118

node-fetch: 2.6.1 node: v16.11.0 npm: 8.0.0 macos: 10.15.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js - Error: only absolute urls are supported - Stack Overflow
It means you are trying to export data and NextJS does not support fetching data from pages/api/* directory. To avoid errors, its better...
Read more >
Error: only absolute urls are supported #481 - GitHub
It looks like there's something wrong with the URL in the fetch method. For me, it solved by changing url in the fetch...
Read more >
TypeError Only absolute URLs are supported - Pipedream
It looks like it expects other environment variables (e.g. that contain the subscription key), as well.
Read more >
TypeError: Only absolute URLs are supported : r/nextjs - Reddit
I keep getting an error even though I have in my configuration file this line of code: const dev = process.env.NODE_ENV !== "production";...
Read more >
Netlify Dev - TypeError: Only absolute URLs are supported
For a new feature I need to start using Netlify functions. In order to run everything locally I started using the Netlify CLI....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found