You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix CORS header caching in GraphQL responses (pimcore#896)
Ensure that that dynamic Access-Control-Allow-Origin header is not cached.
- Remove Access-Control-Allow-Origin header before saving to cache
- Add Access-Control-Allow-Origin dynamically when serving cached responses
based on the incoming request's Origin
This resolves issues with CORS headers being cached alongside GraphQL
responses, which could cause incorrect Access-Control-Allow-Origin values
for clients with different origins.
Copy file name to clipboardexpand all lines: doc/10_GraphQL/10_Events.md
+2
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,8 @@ class GraphQlSubscriber implements EventSubscriberInterface
230
230
-`OutputCacheEvents::PRE_LOAD`: is triggered before trying to load an entry from cache, if cache is enabled. You can disable the cache for this request by setting `$event->setUseCache(false)`. If you disable the cache, the entry won't be loaded nor saved
231
231
-`OutputCacheEvents::PRE_SAVE`: if cache is enabled, it's triggered before saving an entry into the cache. You can use it to modify the response before it gets saved.
232
232
233
+
Uncacheable headers, such as CORS Access-Control-Allow-Origin, are removed from the response before the PRE_SAVE event and re-added after the cached response is loaded.
0 commit comments