Skip to content

Improvement - CORS attributes

Take CORS attributes in .env file.

Example of CORS middleware:

allow_origins=[
    "http://localhost",
    "https://foo.bar",
    "https://toto.fake",
],
allow_credentials=True,
allow_methods=["GET", "POST"],
allow_headers=[
    "X-Requested-With",
    "Content-Type",
    "hx-current-url",
    "hx-request",
    "hx-target",
],

Draft of CORS in .env:

ALLOW_ORIGINS='["http://localhost", "https://foo.bar", "https://toto.fake"]'
ALLOW_CREDENTIALS=True
ALLOW_METHODS='["GET", "POST"]'
ALLOW_HEADERS='["X-Requested-With", "Content-Type", "hx-current-url", "hx-request", "hx-target"]'
Edited by Chosson Ulysse