Report this

What is the reason for this report?

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

Posted on November 7, 2024
  • 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?



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!

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.

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

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.