API fetching problem

I want to fetch an API (i dont own this) and when i fetch it with my browser, postman, CURL, some VSCode extensions for fetching API,... it works fine, perfectly. But when i use fetch() in my node project, i cant fetch the API, the API seems blocked me (it return Blocked by <the website> ) any idea ? please help ❤️
16 Replies
Joao
Joao3mo ago
Probably CORS
Joao
Joao3mo ago
Web Dev Simplified
YouTube
Learn CORS In 6 Minutes
CORS, also known as Cross-Origin Resource Sharing, is something every web developer has to deal with at some point. Chances are if you are watching this video then you are probably dealing with a CORS error right now. In this video I will tell you what CORS is and how you can fix CORS errors. 📚 Materials/References: CORS Blog Article: https:/...
Joao
Joao3mo ago
MDN Web Docs
Cross-Origin Resource Sharing (CORS) - HTTP | MDN
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in ord...
.`noob`.
.`noob`.3mo ago
then it must say blocked by CORS? instead it just say Blocked... (Browser) idk what is (Browser) mean
Jochem
Jochem3mo ago
it'll be so much easier for people to help if you share your code (in a code block, not as a screenshot) and text / screenshots of the error
.`noob`.
.`noob`.3mo ago
its just a simple fetch
let absCooked = await fetch("https://myapi.tk/unlock?key=14142aaaffas", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"sec-ch-ua": "\"Opera GX\";v=\"109\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET"
}).then(r => r.text()).then(r => console.log(r))
let absCooked = await fetch("https://myapi.tk/unlock?key=14142aaaffas", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"sec-ch-ua": "\"Opera GX\";v=\"109\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET"
}).then(r => r.text()).then(r => console.log(r))
i tried edge, opera for the header still same error not really error, the site return this
Blocked by Eggy-Wall.
(Browser)
Blocked by Eggy-Wall.
(Browser)
Jochem
Jochem3mo ago
that really looks like you're trying to circumvent a restriction on the API you're adding a ton of headers that you probably pulled from the network tab?
.`noob`.
.`noob`.3mo ago
its the same without those header
Jochem
Jochem3mo ago
right discussing ways of breaking the TOS for other sites is against Discord TOS
.`noob`.
.`noob`.3mo ago
not breaking tbh their site still working for me
Jochem
Jochem3mo ago
their site is making legitimate use of their API, and from what I see, you're trying to use their API for your own site
.`noob`.
.`noob`.3mo ago
hm that sound right
Jochem
Jochem3mo ago
that's usually not allowed. They are clearly trying to restrict you from doing exactly what you're trying to do
.`noob`.
.`noob`.3mo ago
but why in the network tab i dont really see any checking to block that
Jochem
Jochem3mo ago
that's irrelevant I'm locking this topic, helping you break this other site's TOS can get this server in trouble, so discussion of this topic is simply not allowed in this context
.`noob`.
.`noob`.3mo ago
k
Want results from more Discord servers?
Add your server