Question

NodeJS fetch no longer working when moving from localhost to DO app platform

  • Works on my machine when testing (localhost)
  • No changes made when pushed to DO via github (no code changes)
  • Tested curl syntax with https://reqbin.com/curl using following:
curl --referer www.ea.com "https://proclubs.ea.com/api/nhl/clubs/matches?clubIds=52912&platform=common-gen5&matchType=gameType5" 
-H "Accept-Language: en-US,en;q=0.5" 
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0" 
-H "Connection: keep-alive"

Problem: No response is returned

Code (NodeJS application)

let url = `https://proclubs.ea.com/api/nhl/clubs/matches?clubIds=52912&platform=common-gen5&matchType=gameType5`;
let headers = {
'Accept-Language': 'en-US,en;q=0.5',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0',
'Referer': 'www.ea.com'
}
var options = { "method": "GET", "headers": headers};
console.log("Finished");
const response = await fetch(url, options);
console.log(response);

Any ideas what could be wrong?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 8, 2024

Hey!

Do you get any specific errors when you make the request?

Usually, when you run your code locally, you might not hit strict CORS policies. However, on DigitalOcean’s App Platform, the fetch request is coming from a different origin (your app’s URL). Some APIs, like the one from EA, might block requests from unknown domains or only allow specific origins. Can you confirm if you are seeing any CORS errors?

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.