Comments (7)
Hi there, sorry to hear you are having trouble.
I would love to try and help, can you help me to confirm that there are no CORS headers being returned?
If you run your Flask server, and curl the headers:
curl -I http://127.0.0.1:5000/character_scrape
What is returned? Also, can you confirm that your scrape_char route is not erroring out? Currently, if an unhandled exception occurs, then Flask-Cors is not involved in returning the 500 response, and thus it will not contain CORS headers. This can be tricky to debug, and I will be changing it in the future.
from flask-cors.
Hey, thanks for the fast response! Here's what I see:
brianauron@Resisty ~/character_scraper % curl -I http://127.0.0.1:5000/character_scrape
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 77
Server: Werkzeug/0.9.6 Python/2.7.6
Date: Thu, 31 Jul 2014 01:22:39 GMT
To make sure the endpoint actually works, I've been using wget:
brianauron@Resisty ~/character_scraper % wget -qO- --post-data="character=Alaali&realm=cenarius" localhost:5000/character_scrape
{
"class": "Shaman",
"level": "90",
"race": "Draenei",
"spec tip": "Elemental"
}
which is correct data.
If it matters, I don't see anything unusual in the Flask debug log.
from flask-cors.
I think the last time I posted my code was in a revision without your module. Just now, I tried with telnet:
brianauron@Resisty ~/character_scraper % telnet localhost 5000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /character_scrape HTTP/1.1
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 77
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type
Server: Werkzeug/0.9.6 Python/2.7.6
Date: Thu, 31 Jul 2014 01:55:44 GMT
{
"class": "N/A",
"level": "0",
"race": "N/A",
"spec tip": "N/A"
}
from flask-cors.
@Resisty that looks like the CORS headers are being sent correctly. Can you confirm that the problem is resolved?
from flask-cors.
@wcdolphin No, sorry. Those headers show up in curl/telnet/etc but chrome web developer still shows the no header error and the content fails to show up.
from flask-cors.
Okay, no worries, we will get to the bottom of this! Can you help me by answer a few questions and verify a few of my assumptions?
So presumably you are hosting some HTML/JS from a webserver (eg node http-server, or similar) on port 8000 which is making an AJAX request to a flask app running on 5000, is that correct?
- I see that one of your url params is 'realm', is this service intended to be behind HTTP Auth?
- In the chrome developer console, can you confirm what the AJAX request headers and response are? Is the content what you expect? The status code what you expect?
from flask-cors.
Hi @wcdolphin I really appreciate all the help, but I've just changed my code to rely solely on Flask and not at all on a separate service. Given everything I've tried tonight I think most of this issue is me and not your project, so don't worry about it.
Thanks again!
from flask-cors.
Related Issues (20)
- Next.JS API Call to Flask API POST Endpoint - `Access-Control-Allow-Credentials` is not set properly
- Package prints unexpected DEBUG messages when app runs HOT 2
- Unknown keyword arguments silently ignored HOT 2
- Want to know the next version update time. HOT 1
- Project is dead? HOT 2
- CORS partially fails when making requests with axios in React HOT 3
- Access to fetch at 'http://127.0.0.1:5000/account/summary' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. HOT 2
- v4.0.0 isn't in CHANGELOG.md HOT 1
- two releases 4.0.0 and v4.0.0 HOT 2
- All private network requests unintentionally allowed
- Random Access-Control-Allow-Origin value being returned if Origin request header is not provided HOT 1
- The `4.0.0` release is incorrectly marked as supporting Python 2
- Who to contact for security issues HOT 2
- appropriate citation for the module? HOT 3
- python 3.12 HOT 2
- CORS issue
- Read the Docs is configured to build from a non-existent branch HOT 2
- CVE-2024-1681 response/patching HOT 2
- Security Issue CVE-2024-1681 HOT 1
- documentation is unavilable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-cors.