File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -171,3 +171,32 @@ Start the flask app and you can browse to the swagger UI to try out the API::
171
171
172
172
http://localhost:5000/api/v1/swagger/ui
173
173
174
+
175
+
176
+ CORS
177
+ ====
178
+
179
+ To enable CORS your API Interface (for Flask this is `ApiBlueprint `) needs to
180
+ be wrapped with the CORS wrapper eg::
181
+
182
+ from flask import Flask
183
+ from odinweb.flask import ApiBlueprint
184
+ from odinweb.cors import CORS, AnyOrigin
185
+
186
+ app = flask.Flask(__name__)
187
+
188
+ app.register_blueprint(
189
+ CORS(
190
+ ApiBlueprint(
191
+ api.ApiVersion(
192
+ UserApi()
193
+ )
194
+ ),
195
+ origins=AnyOrigin
196
+ )
197
+ )
198
+
199
+ For customisation the CORS class can easily be inherited to customise how the
200
+ origin is determined (handy if your application is behind a reverse proxy).
201
+ The CORS wrapper also accepts `max_age `, `allow_credentials `, `expose_headers `
202
+ and `allow_headers ` options.
You can’t perform that action at this time.
0 commit comments