Gives error "Only absolute URLs are supported" even though the URL is absolute
See original GitHub issueI 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:
- Get node version 15.2.1
- run
npm install node-fetch@2.6.1
- 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:
- Created 3 years ago
- Reactions:14
- Comments:16 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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