CORS on localhost

hi
i have frappe localserver and react app local too . i want to do login with axios but i face a cors error …
how to solve this on local machine ?

i am facing this problem too.
did you find any solution ?

The only solution i found is to use Oauth provider instead. Could someone help please

Try to set the CORS enabled at the page header. You can check in Google in which code you need to enabled.

Hi thanks for your reply,
i don’t understand what do you mean by enabling CORS at the page header.
your screenshot seems to be a part of the nginx.conf but as i explained above i am willing to enable CORS on localhost with the dev server which is not using any .conf file within the config dir that i can edit

i could not solve this issue , i used a cloud server and use my local react app to test ,
in server i allow localhost, as i remember i could not get it work :frowning:

In production set the nginx headers as mentioned before in this thread. (setting it to wildcard ‘*’ is not secure)

If you need it for development purpose:

In frappe/frappe/app.py, in application(request) function. Place response header just before returning the response

@Request.application
def application(request):

	""" ... """

	response.headers['Access-Control-Allow-Origin'] = '*'
	return response
4 Likes

What about a frappe.cloud instance ? Is it possible to enable CORS ?