Code Monkey home page Code Monkey logo

Comments (6)

itekhi avatar itekhi commented on August 19, 2024

SAME!!

Edit: I read the code of CorsMiddleware and for some reason it checks for Origin header, and if there's no Origin header, it just returns the view. I checked, and my browser didn't provide it. I guess it is a CORS spec? ;)

from django-cors-headers.

jeffthomasweb avatar jeffthomasweb commented on August 19, 2024

Hi, one of the official Docker examples for Django adds local host to the environment file as seen here https://github.com/docker/awesome-compose/blob/master/django/app/example/settings.py#L37. I don’t use Docker but this may be worth a try.

from django-cors-headers.

outwrq avatar outwrq commented on August 19, 2024

@itekhi - Is there something you have implemented to resolve this for a specific origin?

from django-cors-headers.

itekhi avatar itekhi commented on August 19, 2024

@outwrq Hello, I did not. I guess Origin header is only sent by the browser when making cross-origin requests. So I didn't want to put a security hole in my app, so I just switched to Token-based authentication :)

from django-cors-headers.

jeffthomasweb avatar jeffthomasweb commented on August 19, 2024

Looking into this further, your developer tools screenshot displays that you're running a JavaScript file that is making a fetch request to another site. If you look in the Dev Tools console you'll see a more detailed error. If you see an error like:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at [the site fetch() is attempting to access]  (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

you need to add the specific site to CORS_ALLOWED_ORIGINS in the Django settings file. More info can be found here https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin.

from django-cors-headers.

adamchainz avatar adamchainz commented on August 19, 2024

Please read the resources: https://github.com/adamchainz/django-cors-headers#about-cors .

from django-cors-headers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.