Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

707
Views
CORS django 'Acceso-Control-Permitir-Origin'

Estaba tratando de hacer funcionar una solicitud CORS. Con el siguiente código JS, aparece este error: XMLHttpRequest cannot load http://localhost:65491/?token=u80h9kil9kjuu02539buak4r6n&user=~me. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:50303' is therefore not allowed access.

este es el código JS:

 $.ajax({ url: "http://localhost:60906/", data: {token : 'u80h9kil9kjuu02539buak4r6n', user : '~me'}, type: "GET", crossDomain: true, success: function( response ) { alert('Success!' + response); var context = response; } });

Cuando miro la red usando las herramientas de desarrollo de Chrome, veo que no hay un encabezado 'Access-Control-Allow-Origin' . ¡Pero cuando cargo el sitio manualmente, está presente!

Usé el siguiente código para configurar los encabezados:

 response = JsonResponse(simpleWeek) response['Access-Control-Allow-Origin'] = '*' return response

espero alguna ayuda!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Dice No 'Access-Control-Allow-Origin' header is present on the requested resource. lo que significa que su aplicación de servidor necesita ajustes para aceptar solicitudes de origen cruzado. Las solicitudes de origen cruzado no funcionan de manera predeterminada debido a razones de seguridad. Necesita habilitarlos.

Para django hay un paquete mantenido con una buena cantidad de configuraciones solo para esto: https://github.com/ottoyiu/django-cors-headers/

over 4 years ago · Santiago Trujillo Report

0

Después de 2 horas de resolución de problemas, encontré la solución: TYPO en url. Verifique dos veces, tal vez también solucione su problema.

over 4 years ago · Santiago Trujillo Report

0

Para que esto funcione, debes hacer dos cosas:


  • en lugar de https:// solo ingrese http:// en su CORS_ORIGIN_WHITELIST en settings.py

  • agregar CORS_ORIGIN_ALLOW = True en el mismo archivo

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!