-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Angular App with Flask App #6
Comments
For now I think option 1 is the best way to go about it. I wonder if we could just define several resources and change the request URL accordingly based on whether we're on a local server or in production. I'm not too familiar with the intricacies of CORS but I can't imagine it would be too difficult to work around. |
http://better-inter.net/enabling-cors-in-angular-js/ For reference. |
Hey, so I got Angular side of the CORS stuff configured, no problemo. However it also requires the server to return the appropriate headers. The error I'm getting upon making a request is the following: XMLHttpRequest cannot load http://localhost:5000/api/games/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9000' is therefore not allowed access. I believe this can be fixed by adding the appropriate headers on the server side, but I'm not sure how to do that. It should be fixed by adding Access-Control-Allow-Origin and Access-Control-Allow-Credentials headers to the response, so if you could figure out how to do that, that'd be awesome. I think it probably has something to do with that flask-cors download. |
@Diffeomorphism, I included the code that fixes the error you're describing. I believe Tigis already implemented it. To reiterate:
|
Integration can be done in two main ways, I have some experience with both.
using "grunt connect". It merges the /app/static folder with /app/.tmp so if you specify /app/static/styles/main.css in your index.html file, despite the fact that it doesn't exist, it'll find the file at /tmp/styles/main.css and serve it up.
Python WSGI hackery to simulate Grunt Connect
P.S. Here's some sample CORS code:
Some code to send all requests that are undefined to AngularJS
@Diffeomorphism Thoughts?
https://github.com/AlJohri/pickupapp-flask
The text was updated successfully, but these errors were encountered: