feat(issue22/servver-flask): Removes CORS

This commit is contained in:
sovanna 2020-04-15 10:19:03 +09:00
parent 4899bfedc2
commit e116bbf028
4 changed files with 7 additions and 13 deletions

View File

@ -1,5 +1,4 @@
from flask import Flask from flask import Flask
from flask_cors import CORS
from flask_mail import Mail from flask_mail import Mail
from werkzeug.middleware.proxy_fix import ProxyFix from werkzeug.middleware.proxy_fix import ProxyFix
@ -20,12 +19,4 @@ def create_app(cfg=config):
app.register_blueprint(bp_api) app.register_blueprint(bp_api)
CORS(
app,
resources={r'/api/*': {
'methods': ['POST', 'OPTIONS'],
'allow_origins': app.config['CORS_ALLOWED_ORIGINS'].split(','),
'allow_headers': app.config['CORS_ALLOWED_HEADERS'].split(','),
}})
return app return app

View File

@ -8,6 +8,13 @@ from app.api import bp
from app import mail from app import mail
@bp.after_request
def after(response):
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Headers"] = "*"
return response
@bp.route("/rfq", methods=["POST"]) @bp.route("/rfq", methods=["POST"])
def send_rfq(): def send_rfq():
payload = request.json payload = request.json

View File

@ -16,6 +16,3 @@ MAIL_USERNAME = getenv("FLASK_MAIL_USERNAME")
MAIL_PASSWORD = getenv("FLASK_MAIL_PASSWORD") MAIL_PASSWORD = getenv("FLASK_MAIL_PASSWORD")
MAIL_RECIPIENT = getenv("FLASK_MAIL_RECIPIENT") MAIL_RECIPIENT = getenv("FLASK_MAIL_RECIPIENT")
CORS_ALLOWED_ORIGINS = getenv("FLASK_CORS_ORIGINS")
CORS_ALLOWED_HEADERS = getenv("FLASK_CORS_ALLOW_HEADERS")

View File

@ -1,7 +1,6 @@
blinker==1.4 blinker==1.4
click==7.1.1 click==7.1.1
Flask==1.1.2 Flask==1.1.2
Flask-Cors==3.0.7
Flask-Mail==0.9.1 Flask-Mail==0.9.1
itsdangerous==1.1.0 itsdangerous==1.1.0
Jinja2==2.11.1 Jinja2==2.11.1