[MAGNOLIA-8057] DOC: Configure CORS using decoration Created: 13/Apr/21 Updated: 06/May/21 |
|
| Status: | Selected |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Neutral |
| Reporter: | Christopher Zimmermann | Assignee: | Martin Drápela |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoR: |
Empty
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
Include in documentation a common and convenient way to configure CORS which is by decoration of a site/ multisite config.yaml
Here are notes from mmichel which may be useful for this task:
CORS headers
One of the common requirements when working on a light development project, is to get the CORS (Cross-Origin Resource Sharing) configuration right. Did you know that Magnolia allows to do this with less configuration than ever before?
Indeed, although not documented on the thorough documentation page, a consequence of module configuration decoration through YAML files totally makes it possible.
The prerequisites to configure CORS are indeed:
Since this configuration 1. lives in the modules workspace, 2. already exists, then that means we can use definition decoration from the scope of a light module to extend it. Create the following file at the following path: modules/<YOUR_LIGHT_MODULE>/decorations/multisite/config.yaml.
In that file, you can configure CORS as you would traditionally:
sites: fallback: cors: fallback: uris: rest: patternString: /.rest/* allowedOrigins: allowedMethods: - GET allowedHeaders: - Accept - Content-Type - Origin - X-PINGOTHER - X-Requested-With
Except you get the following benefits:
|
| Comments |
| Comment by Maxime Michel [ 14/Apr/21 ] |
|
Would be great to publish this after my technical newsletter article, otherwise, well, there's no point in me having written that for that channel in the first place. |