Next.js Discord

Discord Forum

Call external API from local dev

Unanswered
Chilean jack mackerel posted this in #help-forum
Open in Discord
Chilean jack mackerelOP
Hello, I need little help with my problem, has anyone solved the problem with calling a external service API from a NextJS dev application? I need to get data from the API, but Cloudflare's protection blocks it with a 403 error, which tells me that I need to confirm that I am human. Essentially, this requires a normal call from a normal production application. Postman works well with this, but on my Dev application, it doesn't work. Maybe I need to play around with cookies somehow, but I don't have any ideas yet. It's not a complicated system, I just need it for a single-window application to test some functionality.

Attached my Postman headers and request on server side. (Btw I tried all headers and seems no work)

Never had experience to do something like this especially in NextJS app and I'm completely new in this, maybe I do something fully wrong

5 Replies

Cinnamon Teal
Looks like you have a cookie in your Postman requests, which is probably used for auth.

You will need to attach that cookie in your app requests as well.

You won't need to add all those headers you see in Postman inside your app fetch call. Having the cookie should be enough.
@Cinnamon Teal Looks like you have a cookie in your Postman requests, which is probably used for auth. You will need to attach that cookie in your app requests as well. You won't need to add all those headers you see in Postman inside your app fetch call. Having the cookie should be enough.
Chilean jack mackerelOP
Thank you for answer. I'm not sure about that, I tried literally everything possible to use in header, but unfortunately everytime I get same answer on my local server. It works only in Postman
@B33fb0n3 in your postman, yo ucan click this button (see huge arrow). After that, you automatically get the whole code, that you need to reproduce exactly the same request. Copy + Paste and test and you see it's working 🙂 \- It includes *everything* that postman know about your request
Chilean jack mackerelOP
Actually not 😆 . Good advice, I didn't know about this, but cloudflare is smarter and my request was blocked again, I just did exactly same request from Postman few seconds ago, I tried proxy also. I mean I have task to do this, and actually I think it's included in task to solve this problem, but I'm not sure if I need to contact them to get some guide or allowance