0

I'm using django code for the app server, which is available at https://github.com/AgoraIO/Agora-Chat-API-Examples/tree/main/chat-app-server-django, and this for the web SDK, which is available at https://github.com/AgoraIO-Usecase/AgoraChat-web. i am getting the CORS error. Do I need to enable any Agora settings. A call can also be put up, right? Getting this error : The CORS policy has prohibited access to XMLHttpRequest at 'https://localhost:8000/app/user/register' from origin 'http://localhost:3000': Preflight response fails access control verification: The requested resource doesn't have a 'Access-Control-Allow-Origin' header.

Access-Control-Allow-Origin: *

2 Answers2

0

Try installing this package in the console

python -m pip install django-cors-headers

Add it to installed apps

INSTALLED_APPS = [
...
'corsheaders',
...]

Add it to middleware

MIDDLEWARE = [
...
'corsheaders.middleware.CorsMiddleware',
...]

Now add a list of origins to settings.py

CORS_ALLOWED_ORIGINS = [
"https://example.com",
"https://sub.example.com",
"http://localhost:8080",
"http://127.0.0.1:8080"]

Also set CORS_ORIGIN_ALLOW_ALL to false.

Hope this helps.

IdiotCoder
  • 24
  • 6
0

If your intent is local development, you have to disable CORS checking in your browser.

See the posts below