Ah, the 415 status code in a CORS preflight response is the key clue here!
🔍 What Does HTTP Status Code 415 Mean?
415 Unsupported Media Type
This means your server does not accept the Content-Type of the request you're sending—especially in your POST request during the CORS preflight check.
Since you mentioned you're using a POST method to send a GUID, and it's not working (especially in Safari), this is what's happening:
🧩 What’s Happening Under the Hood?
When you make a POST request with a custom header (like Content-Type: application/json), browsers, including Safari, first send a “preflight” request—an OPTIONS request to check if the server will accept the real request.
If the preflight request gets a 415, the browser won't send the actual POST. This breaks your workflow.
✅ Fix It Step-by-Step
✅ 1. Make Sure Your Server Accepts the Content-Type
If you're sending JSON (which is common when including a GUID), make sure:
Client:
fetch("https://api.example.com/endpoint", {
method: "POST",
headers: {
"Content-Type": "application/json", // This triggers preflight
},
body: JSON.stringify({ guid: "your-guid" }),
});
Server: Ensure it accepts JSON:
- Allow
Content-Type: application/json
- Handle
OPTIONS preflight requests properly
For example, if using Express (Node.js):
app.use(express.json());
app.options('/endpoint', (req, res) => {
res.set('Access-Control-Allow-Origin', '*');
res.set('Access-Control-Allow-Methods', 'POST, OPTIONS');
res.set('Access-Control-Allow-Headers', 'Content-Type');
res.sendStatus(204);
});
app.post('/endpoint', (req, res) => {
const guid = req.body.guid;
res.send(`GUID received: ${guid}`);
});
✅ 2. Handle the CORS Preflight (OPTIONS Request)
Your server must respond with HTTP 200 or 204 for the OPTIONS request and include headers like:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
If you're not explicitly handling OPTIONS requests on the server, many frameworks will default to rejecting them, hence the 415.
✅ 3. Double-Check Content-Type and Method
If you're not sending JSON, consider switching to a "simple" request to avoid preflight entirely:
fetch('https://api.example.com/endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded' // this avoids preflight
},
body: `guid=${encodeURIComponent(guid)}`
});
This type of request does NOT trigger a preflight and will work even where CORS is restricted — including Safari.
🧪 Quick Fix Summary
| Issue | Solution |
|---|
415 Unsupported Media Type | Check that server handles Content-Type used |
| Preflight CORS failing | Handle OPTIONS requests on your server correctly |
| Safari being strict | Ensure CORS headers are complete & correct |
| Easier option | Use application/x-www-form-urlencoded instead of JSON to skip preflight |
Let me know:
- Which server/backend you're using (Express, Flask, ASP.NET, etc.)
- What kind of body/content you're sending in the
POST
- And whether it’s a same-origin or cross-origin request
...and I can send you exact backend code to fix it!