If you’re wiring a frontend to the Shopware API and the browser starts yelling about CORS, the problem usually isn’t Shopware itself. It’s the config around it: reverse proxies, app servers, auth headers, cookies, and preflight handling.
I’ve seen teams lose hours on this because the API works fine in Postman, curl, or the Shopware admin, but fails instantly in the browser. That gap is the whole CORS story: browsers enforce it, backend clients don’t.
Here are the most common CORS mistakes with Shopware API setups and the fixes that actually work.
Mistake #1: Testing with Postman and assuming CORS is fine
This one gets almost everyone once.
You send a request to /store-api or /api, it returns 200 OK, so you assume the frontend should work too. Then your browser blocks it.
That’s because CORS is not an API feature in the usual sense. It’s a browser access control layer. Postman doesn’t care whether your response includes:
Access-Control-Allow-Origin: https://shop.example
The browser absolutely does.
If you want to inspect what headers your API really returns, use browser devtools or a header inspection tool like HeaderTest. I like checking both the actual request and the preflight OPTIONS response because one broken header there is enough to kill the whole flow.
Mistake #2: Only configuring CORS on the “real” request, not the preflight
A lot of Shopware API requests trigger a preflight request first:
AuthorizationheaderContent-Type: application/json- non-simple methods like
PUT,PATCH,DELETE
The browser sends OPTIONS before the real request and expects a valid response.
A broken setup looks like this:
GET /api/product
Access-Control-Allow-Origin: https://frontend.example
But the OPTIONS /api/product response is missing CORS headers or returns 405 Method Not Allowed.
That means the browser never even sends the real GET.
Fix
Make sure your web server or app stack handles OPTIONS for Shopware API routes and returns the expected headers.
A typical response should look like:
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://frontend.example
Access-Control-Allow-Methods: GET, POST, PATCH, DELETE, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type, sw-access-key
Access-Control-Max-Age: 86400
Vary: Origin
If you’re running Shopware behind Nginx, a minimal example might look like this:
location /api/ {
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "https://frontend.example" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type, sw-access-key" always;
add_header Access-Control-Max-Age 86400 always;
add_header Vary "Origin" always;
return 204;
}
add_header Access-Control-Allow-Origin "https://frontend.example" always;
add_header Vary "Origin" always;
proxy_pass http://php-fpm-or-upstream;
}
The always flag matters. Without it, Nginx may skip headers on error responses, which creates maddeningly inconsistent behavior.
Mistake #3: Using * with credentials
This is a classic CORS footgun.
People see public APIs returning:
Access-Control-Allow-Origin: *
That can be perfectly valid. GitHub does it on api.github.com, for example:
access-control-allow-origin: *
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset, Warning
That works because GitHub isn’t trying to allow browser credentials from every origin.
With Shopware, if your frontend sends cookies or uses fetch(..., { credentials: "include" }), * is invalid. Browsers reject it.
Broken example
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
That combination does not work.
Fix
Return the exact origin instead:
Access-Control-Allow-Origin: https://frontend.example
Access-Control-Allow-Credentials: true
Vary: Origin
And on the frontend:
fetch("https://shop.example/store-api/account/customer", {
credentials: "include",
headers: {
"Content-Type": "application/json"
}
})
If you don’t need cookies, don’t use credentials. Simpler CORS is better CORS.
Mistake #4: Forgetting custom Shopware headers in Access-Control-Allow-Headers
Shopware integrations often use headers like:
sw-access-keyAuthorizationContent-Type
If your frontend sends one of these and your preflight response doesn’t explicitly allow it, the browser blocks the request.
Broken preflight response
Access-Control-Allow-Headers: Content-Type
But the request sends:
Authorization: Bearer ...
sw-access-key: ...
Fix
Allow every header your frontend actually sends:
Access-Control-Allow-Headers: Authorization, Content-Type, sw-access-key
Don’t just copy a giant list from random blog posts. Match your real traffic.
Mistake #5: CORS configured in Symfony, but stripped or replaced by Nginx/CDN
Shopware runs on Symfony, and many teams configure CORS in the app layer using NelmioCorsBundle or custom event listeners. That can work. But if Nginx, Apache, Cloudflare, or a load balancer rewrites headers, your app config may never reach the browser intact.
I’ve seen this exact mess:
- Symfony returns the right CORS headers
- Nginx adds a second
Access-Control-Allow-Origin - CDN caches a response for the wrong origin
- browser rejects the whole thing
Fix
Pick one place to own CORS if possible. My preference:
- handle CORS at the edge or reverse proxy for consistency
- keep app-level CORS only if you genuinely need route-aware behavior
Then verify the final response in the browser network panel, not just app logs.
If multiple layers are involved, check for duplicate headers like:
Access-Control-Allow-Origin: https://frontend.example
Access-Control-Allow-Origin: *
That response is broken.
Mistake #6: Missing Vary: Origin
This is a quiet bug that only shows up in production, usually behind a cache.
If your API dynamically reflects allowed origins, caches need to know the response changes based on the Origin request header. Without Vary: Origin, a response generated for one origin can be cached and served to another.
Fix
Add:
Vary: Origin
Any time Access-Control-Allow-Origin is dynamic.
This matters a lot for Shopware setups behind Varnish, Nginx cache, or a CDN.
Mistake #7: Exposing too few response headers
CORS doesn’t just control whether the request is allowed. It also controls which response headers JavaScript can read.
If your frontend needs pagination, rate limit, or resource metadata from response headers, you may need Access-Control-Expose-Headers.
GitHub is a good real-world example here. Their exposed headers include useful values like ETag, Link, and rate-limit fields:
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset, Warning
If your Shopware API returns useful custom headers and your frontend can’t read them, this is probably why.
Fix
Expose only the headers your frontend needs:
Access-Control-Expose-Headers: ETag, Link, Location
Then in JavaScript:
const res = await fetch("https://shop.example/store-api/product");
console.log(res.headers.get("ETag"));
console.log(res.headers.get("Link"));
Mistake #8: Treating CORS as authentication
CORS is not auth. It does not protect your Shopware API from server-side abuse, scripts outside the browser, or direct HTTP clients.
I still run into setups where someone says, “We’re safe because only our frontend origin is allowed.”
Nope. That only restricts what browsers allow JavaScript to read. Anyone can still send requests with curl unless you also enforce real authentication and authorization.
Fix
Use CORS for browser access control, not as a security boundary.
For actual protection:
- validate tokens
- use proper session handling
- lock down admin/API endpoints
- configure cookies with
Secure,HttpOnly, andSameSite - review your broader header policy too
If you’re working through security headers beyond CORS, csp-guide.com is worth keeping around for CSP and related hardening.
Mistake #9: Forgetting cookie SameSite rules and blaming CORS
This one is sneaky.
Your CORS headers look correct. Access-Control-Allow-Origin is specific. Access-Control-Allow-Credentials: true is present. But session cookies still don’t get sent.
That may not be CORS at all. It may be cookie policy.
For cross-site requests, modern browsers usually require:
Set-Cookie: session=...; Secure; HttpOnly; SameSite=None
If SameSite=Lax or Strict, the browser may drop the cookie even though CORS is configured properly.
Fix
If your Shopware frontend is on a different site and relies on cookies, review cookie attributes carefully.
A practical baseline config
For many Shopware API browser integrations, this is the baseline I’d start with:
Access-Control-Allow-Origin: https://frontend.example
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type, sw-access-key
Access-Control-Expose-Headers: ETag, Link, Location
Access-Control-Max-Age: 86400
Vary: Origin
Then test three cases:
- preflight
OPTIONS - actual API request
- error responses like
401and403
If CORS headers disappear on auth failures, the browser will show a misleading CORS error and hide the real backend problem. I hate that behavior, but it’s normal.
Final debugging checklist
When Shopware API CORS breaks, I check these in order:
- Does the browser send an
OPTIONSpreflight? - Does the preflight return
2xxwith the right allow headers? - Is
Access-Control-Allow-Originexact, not*, when credentials are used? - Are
Authorization,Content-Type, andsw-access-keyallowed? - Is
Vary: Originpresent for dynamic origins? - Are proxies or CDNs duplicating or stripping headers?
- Are cookies blocked by
SameSiterather than CORS? - Do error responses include CORS headers too?
Most CORS issues with Shopware come down to one of those.
CORS isn’t hard because the rules are complex. It’s hard because one missing header in one layer breaks everything, and the browser error messages are usually terrible. Once you focus on the exact request/response pair in devtools, the fix is usually pretty boring. Which, honestly, is what you want.