skip to Main Content

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

Answers


  1. 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.

    Login or Signup to reply.
  2. If your intent is local development, you have to disable CORS checking in your browser.

    See the posts below

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search