Skip to content

Commit

Permalink
fix(api): cors for branches environments (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudambro authored Jul 31, 2023
1 parent 180e4b1 commit fb48745
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
12 changes: 10 additions & 2 deletions api/ecosante/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import re

from celery.signals import after_setup_logger, after_setup_task_logger
from flask import Flask, g
Expand Down Expand Up @@ -106,7 +107,14 @@ def create_app(testing=False):
db.init_app(app)
migrate.init_app(app, db)
assets_env.init_app(app)
cors.init_app(app)

if app.config['ENV'] == "production" or app.config['ENV'] == "dev":
cors.init_app(app, resources={r"/*": {
"origins": re.compile(r"^https://([a-z0-9-]+\.)*fabrique\.social\.gouv\.fr$")
}})
else:
cors.init_app(app)

sib.configuration.api_key['api-key'] = os.getenv('SIB_APIKEY')
configure_celery(app)
configure_cache(app)
Expand Down Expand Up @@ -142,4 +150,4 @@ def create_app(testing=False):

rebar.init_app(app)

return app
return app
Binary file added frontend/.DS_Store
Binary file not shown.

0 comments on commit fb48745

Please sign in to comment.