Diagnosing browser-only API failures beyond CORS with DevTools: cookies not stored or not sent (SameSite, Secure, Domain, credentials mode, third-party blocking), mixed content, HTTP caching and service workers serving stale data, and what Postman does differently from a browser.
Postman isn't a browser: it ignores the same-origin policy, SameSite, mixed-content blocking and caching rules, and keeps its own cookie jar. So I reproduce in the browser with DevTools open. In Network, I click the login response and look at Set-Cookie: Chromium shows a warning icon explaining why a cookie was blocked (e.g. Secure over HTTP, SameSite=None without Secure, wrong Domain). In Application → Cookies I check what was actually stored, then check the next request's Cookie header. Typical fixes: credentials: 'include' for cross-origin calls, correct SameSite/Secure, or better, serve SPA and API from one origin. For mixed content, find the http:// URL (often a redirect built behind a proxy without forwarded headers). For stale data, the Size column shows (disk cache) or (ServiceWorker); fix Cache-Control. Trade-off: patching flags per symptom works, but same-origin hosting removes the whole class.
"First I'd stop trusting Postman as evidence. It has no same-origin policy, it doesn't apply SameSite or third-party cookie rules, it doesn't block mixed content, and it doesn't use the browser's HTTP cache or a service worker. So 'it works in Postman' only proves the endpoint works, not that a browser is allowed to use it the way the app does. I reproduce in a clean browser profile with DevTools open, 'Preserve log' ticked, and look at the evidence request by request.
For the cookie problem, I click the login response in the Network panel and open the Cookies tab. Chromium marks rejected
Set-Cookieheaders with a reason: 'This Set-Cookie was blocked because it had the Secure attribute but came over an insecure connection', or 'SameSite=None without Secure', or 'Domain attribute invalid for the current host'. If it was stored, I check Application → Cookies and then the next request's request headers. If the cookie's there but not sent, it's eithercredentialsmissing on a cross-originfetch, or SameSite: the SPA onmyapp.azurestaticapps.netand the API onmyapi.azurewebsites.netare different sites, so aLaxcookie is never sent and aNonecookie is a third-party cookie that Safari blocks outright. For example, at [company] our [customer portal] login 'worked' for Chrome users and failed for every iPhone user until we put the API behind the same domain; [support tickets dropped by X].Mixed content shows as a console error naming the
http://URL. Usually the page is HTTPS but the API base URL, or aLocationheader from a redirect, is HTTP because the app behind a TLS-terminating proxy doesn't know the original scheme;UseForwardedHeadersfixes the generated URLs. Stale data I check in the Size column:(disk cache),(memory cache)or(ServiceWorker)means the server never saw the request. The mistake I see is setting random cookie flags until it works. The structural fix is one origin, correctCache-Controlon user data, and forwarded headers configured once."
| Symptom | DevTools evidence | Likely cause | Fix |
|---|---|---|---|
| Login 200, next call 401 | Set-Cookie has warning icon | Secure on http, SameSite=None without Secure, bad Domain |
Correct attributes; HTTPS locally (dotnet dev-certs https) |
| Cookie stored, not sent | Request has no Cookie header | credentials not include; SameSite cross-site |
credentials:'include' + CORS AllowCredentials, or same origin |
| Works in Chrome, fails in Safari | Safari Web Inspector shows cookie missing | Third-party cookie blocked (ITP) | Same-site domains or BFF on same origin |
| "Mixed Content" in console | Request shows (blocked:mixed-content) | http:// URL from config or redirect |
HTTPS base URL, UseForwardedHeaders |
| Old data after update | Size: (disk cache) / (ServiceWorker) | Missing/long Cache-Control, SW caching API |
Cache-Control: no-store/private, no-cache; fix SW strategy |
| Fails only for some users | Extensions or corporate proxy | Ad blockers block /track, /ads paths |
Test in clean profile |
| Behaviour | Browser | Postman |
|---|---|---|
| Same-origin policy / CORS | Enforced | Ignored |
| SameSite, third-party blocking | Enforced | Ignored |
| Mixed content | Blocked | N/A |
| HTTP cache, service workers | Used | Not used |
Forbidden headers (Origin, Cookie) |
Set by browser only | You can set anything |
A SPA on Azure Static Apps called an API on a separate azurewebsites.net host with a SameSite=None; Secure session cookie. Chrome worked; Safari and Firefox with strict tracking protection failed, about 31% of logins. Routing /api through the same custom domain (Front Door) and switching the cookie to __Host- with SameSite=Lax brought login failures to zero and removed every preflight.
Checks that the candidate can diagnose browser-specific failures methodically with DevTools instead of guessing, and knows what Postman hides.
Green flags
Red flags
login response -> Set-Cookie: sid=...; Secure; HttpOnly; SameSite=None
CHECK 1: is it acceptable? (Secure needs https, None needs Secure,
Domain must match, __Host- rules, third-party policy)
-> stored in jar (Application > Cookies) or rejected (warning icon)
next fetch -> CHECK 2: credentials mode allows cookies? (same-origin / include)
CHECK 3: domain + path match?
CHECK 4: SameSite allows this cross-site context?
CHECK 5: third-party cookie allowed / partitioned?
-> Cookie: sid=... (visible in request headers)
Each check has a matching DevTools signal. Chromium's Network → Cookies tab has a "show filtered out request cookies" option that lists cookies not sent with the reason.
azurewebsites.net and azurestaticapps.net are on the public suffix list, so a.azurewebsites.net and b.azurewebsites.net are different sites, not just different origins. Cookies can't be shared between them and every call is cross-site. A custom domain (app.example.com.au, api.example.com.au) makes them same-site; path routing on one host makes them same-origin.
Browsers block active mixed content (scripts, fetch/XHR, iframes) on HTTPS pages and auto-upgrade or block passive content (images). Behind Azure Front Door, App Gateway or a Kubernetes ingress, TLS ends at the proxy and Kestrel sees http. Without ForwardedHeadersOptions, Request.Scheme is http, so Url.Action, CreatedAtRoute, OIDC redirect URIs and UseHttpsRedirection all produce or bounce through http:// URLs.
fetch() -> Service Worker (if registered) -> memory cache -> HTTP disk cache -> network -> CDN -> API
If the API sends no Cache-Control, browsers may apply heuristic caching to GETs with a Last-Modified header. A service worker using cache-first for /api/* will serve yesterday's data forever. DevTools → Application → Service Workers lets you unregister and bypass for network.
Use a fresh profile or incognito, tick Disable cache while debugging (and untick it to reproduce caching bugs), Preserve log across redirects, and export a HAR to share (scrub cookies and tokens first: HAR files contain them).
http://localhost:5000 that sets a Secure cookie and watch the blocked-cookie warning.credentials: 'include' and confirm no Cookie header is sent.https and the API on http to trigger a mixed-content error.Cache-Control from a GET with Last-Modified and observe (disk cache) on reload navigation.Server fixes for the three browser-only failure types, plus the client call.
// Program.cs (.NET 10)
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
// 1. Behind Front Door / ingress: trust forwarded scheme so generated URLs are https
builder.Services.Configure<ForwardedHeadersOptions>(o =>
{
o.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
o.KnownIPNetworks.Clear(); // .NET 10 name; restrict to your proxy ranges in real config
o.KnownProxies.Clear();
});
// 2. Session cookie that the browser will accept and send (same-origin hosting)
builder.Services.AddAuthentication().AddCookie(o =>
{
o.Cookie.Name = "__Host-sid";
o.Cookie.SecurePolicy = CookieSecurePolicy.Always;
o.Cookie.SameSite = SameSiteMode.Lax; // works because SPA and API share one origin
o.Cookie.HttpOnly = true;
o.Events.OnRedirectToLogin = ctx => { ctx.Response.StatusCode = 401; return Task.CompletedTask; }; // API: 401, not 302
});
builder.Services.AddAuthorization();
var app = builder.Build();
app.UseForwardedHeaders(); // first
app.UseAuthentication();
app.UseAuthorization();
// 3. User-specific data must not be cached by browsers or shared caches
app.MapGet("/api/me/orders", (HttpResponse res) =>
{
res.Headers.CacheControl = "no-store";
return TypedResults.Ok(new[] { new { Id = 1, Status = "Paid" } });
}).RequireAuthorization();
app.Run();
// Client: relative URL = same origin, no CORS, cookies sent by default, no mixed content risk
const res = await fetch('/api/me/orders', { headers: { Accept: 'application/json' } });
// If you truly must call another origin, cookies need this AND a CORS policy with AllowCredentials
// await fetch('https://api.example.com.au/api/me/orders', { credentials: 'include' });
SameSite=None to make cookies flow. Why it is wrong: It's a third-party cookie when sites differ; Safari and Firefox block it, and it weakens CSRF protection. Instead: Same-site domains or same-origin hosting.Secure cookies. Why it is wrong: Browsers reject them (localhost exceptions vary). Instead: Run HTTPS locally with dotnet dev-certs https --trust.http:// API base URLs in frontend config. Why it is wrong: HTTPS pages block them. Instead: Relative URLs or HTTPS per environment.Location headers become http://. Instead: UseForwardedHeaders with known proxies configured.fetch follows it and gets HTML, which looks like a JSON parse error. Instead: Return 401/403 for API paths.Cache-Control on user data. Why it is wrong: Heuristic caching or a service worker serves stale or another session's data. Instead: no-store or private, no-cache explicitly.Most browser-only failures come from the deployment topology, not the code: separate hosts on public-suffix domains, TLS termination at a proxy, and a CDN or service worker in front. A senior fixes the topology once (custom domain, path-based routing to the API, forwarded headers, explicit cache policy) and adds a cross-browser smoke test, rather than tuning cookie flags per bug.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Same origin via Front Door/ingress path routing | Your SPA + your API | Routing config, one domain | Third-party consumers |
| Same-site subdomains + CORS with credentials | Teams own separate hosts | Preflights, SameSite=Lax still works | Public-suffix default hosts |
SameSite=None; Secure cross-site |
Unavoidable embedded/iframe cases | Blocked in Safari/Firefox, CSRF risk | Anything else |
Measure with Playwright tests across Chromium, Firefox and WebKit in CI, and with Application Insights browser telemetry segmented by browser: a failure rate that's high on Safari only points straight at cookie policy.
The same-origin policy stops JavaScript on one origin (scheme + host + port) from reading responses from another, so a malicious page can't read your bank's API with your cookies. CORS is the server's way to opt in. For a simple request (GET, HEAD or POST with only safelisted headers and a form or text/plain body) the browser sends it and then checks Access-Control-Allow-Origin before handing the response to your code. Anything else, such as a JSON POST, a PUT or an Authorization header, first gets an OPTIONS preflight asking permission for that method and those headers. Sending cookies needs credentials: 'include' and Access-Control-Allow-Credentials: true with an explicit origin. The key trade-off: the browser enforces it but the server's headers decide, and CORS is not security for your API: non-browser clients ignore it.
SameSite tells the browser whether to send a cookie on cross-site requests. Strict: never cross-site. Lax: cross-site only on top-level GET navigations (clicking a link), not on cross-site POSTs, iframes or fetch. None: always, and it must also be Secure. 'Site' means scheme plus registrable domain, so app.example.com.au and api.example.com.au are the same site.
Chromium now treats cookies without the attribute as Lax by default, which broke flows that relied on cross-site POSTs, most famously OpenID Connect form_post callbacks: the identity provider POSTs back to /signin-oidc, so the correlation and nonce cookies must be SameSite=None; Secure, which ASP.NET Core sets for you over HTTPS. The trade-off: Strict is safest but hurts UX; None is needed for embedding and federation but loses CSRF protection.
CONNECT. HttpClient picks it up from system settings or HTTP_PROXY/HTTPS_PROXY/NO_PROXY.Behind a reverse proxy, the app sees the proxy's IP and often plain http. The proxy passes the originals in X-Forwarded-For and X-Forwarded-Proto, but ASP.NET Core only applies them via the ForwardedHeaders middleware, and by default only trusts proxies on loopback. So UseHttpsRedirection sees http, redirects to https, the proxy forwards as http again: a loop.
Fix: UseForwardedHeaders first, configured with the proxy's IPs or network in KnownProxies/known networks. Do not trust all sources, or clients can spoof their IP and scheme.
How to tell it (STAR)
**S:** Our [customer portal] had a React SPA and an ASP.NET Core API on two different Azure default hostnames, with cookie sessions. **T:** iPhone users couldn't stay logged in and I was asked to find out why within [a day]. **A:** Postman worked, so I reproduced in Safari with Web Inspector and saw the session cookie was stored but never sent: with two separate sites it was a third-party cookie, which Safari blocks. I routed `/api` through Front Door on our custom domain so everything was same-origin, changed the cookie to `__Host-` with `SameSite=Lax`, deleted the CORS policy, and added WebKit to our Playwright smoke tests. **R:** Safari login failures went from [about 30%] to zero, preflight requests disappeared, and [support tickets about login dropped by X per week].
Last updated 23 Nov 2026.