Next.js Discord

Discord Forum

Request Error (CORS)

Unanswered
Filipino Venus posted this in #help-forum
Open in Discord
Filipino VenusOP
I can't make a request from a form to search for profiles, I get a cors error and when I use the same request in another page it lets me and brings me the data correctly.
can i fix it?

4 Replies

Filipino VenusOP
can someone help me?
you either need to fix the issue in the API you are calling (because it is not correctly configured for CORS requests) or you need to proxy this request from your own server (in a route handler, for example)
Filipino VenusOP
@Rafael Almeida my API is created with java
@Filipino Venus <@258390283127881728> my API is created with java
Toyger
then you need to configure your java api for allowing cors requests
by adding headers for example like:
Access-Control-Allow-Origin: https://foo.example
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: X-PINGOTHER, Content-Type

more likely your framework that you use on backend already have cors feature that can be configured.