What Is a Preflight Request? CORS Checks Explained
Scrapeless Agent Browser runs browser-based workflows in which target pages remain subject to the browser’s cross-origin request rules.
TL;DR
- A CORS preflight checks permission for a proposed cross-origin request. The browser sends an OPTIONS request before certain application requests.
- A successful OPTIONS status is insufficient. The browser must validate the required CORS fields against the proposed operation.
- CORS permission does not replace API authorization. The resource server still checks credentials and operation permissions.
- Command-line success does not prove browser access. Browser origin policy adds checks that a server-side HTTP client does not enforce.
A Preflight Asks About a Proposed Browser Request
A CORS preflight is an HTTP OPTIONS request that a browser sends to check whether a server permits a particular cross-origin request. It describes the calling origin, the intended method, and relevant request-field names. If the server’s response satisfies the browser’s checks, the browser can proceed with the application request. The preflight is a permission negotiation in the browser’s access model, not the application operation itself.
The Fetch Standard CORS model defines this behavior. An origin is determined by scheme, host, and port, so two URLs can belong to different origins even when their domains look closely related. A frontend served from one origin and an API served from another may need CORS configuration for browser JavaScript to access the API response.
CORS stands for Cross-Origin Resource Sharing. It allows a server to opt into certain cross-origin browser interactions within the same-origin security model. The policy is enforced by the browser, while the server declares what it permits through response fields. An application cannot solve a denied cross-origin request by adding response-permission fields to its own outgoing request.
Not Every Cross-Origin Request Is Preflighted
Some cross-origin requests fall within the CORS-safelisted method and field rules and do not need a preflight. The exact conditions include the method, request-field values, and relevant Fetch behavior. A GET request with a non-safelisted field can require a preflight, while a suitably constrained POST can avoid one. The method name alone is therefore an incomplete decision rule.
Common triggers include methods outside the safelisted set, an Authorization field, and a JSON content type that is not among the safelisted media types. Those examples explain many browser network traces, but the full test belongs to the Fetch rules. Avoid describing all GETs as simple or all POSTs as preflighted. Inspect the actual request configuration.
The browser preflight request explanation distinguishes the preliminary OPTIONS request from the actual request. A server can receive requests that do not need preflight while the browser still refuses to expose their responses to JavaScript. CORS therefore should not be described as a universal barrier that prevents every cross-origin request from reaching a server.
The Browser Describes the Intended Method and Fields
The preflight includes Origin to identify the calling origin. Access-Control-Request-Method names the method the browser proposes to use for the actual request. Access-Control-Request-Headers lists relevant request-field names that need permission. These are descriptions of a proposed operation; they do not mean the OPTIONS request itself performs that operation or carries the application’s full payload.
The server responds with fields describing permitted origins, methods, and request fields as applicable. The browser evaluates those declarations against the proposed request. A generic successful OPTIONS handler is insufficient when it omits the required permission or grants a different method. Keep the comparison precise so the diagnostic identifies which part of the policy failed.
| Field | Direction | Meaning in the Exchange |
|---|---|---|
| Origin | Browser request | Origin of the calling page |
| Access-Control-Request-Method | Preflight request | Method proposed for the application request |
| Access-Control-Request-Headers | Preflight request | Request-field names requiring permission |
| Access-Control-Allow-Origin | Server response | Origin access the server permits |
| Access-Control-Allow-Methods | Preflight response | Permitted request methods |
| Access-Control-Allow-Headers | Preflight response | Permitted request-field names |
| Access-Control-Max-Age | Preflight response | Permitted lifetime for caching the preflight result |
An application request remains a separate exchange. Once it arrives, the API validates its credentials, parameters, and permissions. Its response also needs the appropriate CORS fields for browser access. Passing the preliminary check does not make a later unauthorized or malformed application operation successful, and it does not exempt the actual response from origin-policy handling.
Credentials Make Origin Configuration More Specific
Credentialed browser requests require the CORS response policy to match the credentials mode and requesting origin. A wildcard allowed origin cannot be used as a general substitute for an explicit origin when exposing a credentialed response. The server also needs the appropriate credential permission. Configure these fields from a controlled origin policy instead of reflecting arbitrary input without checking it.
Cookies introduce additional rules beyond CORS. A request can satisfy its CORS policy while cookie delivery is constrained by cookie attributes or browser privacy behavior. Conversely, the presence of a cookie does not establish that a server accepted the session. Keep cookie delivery, CORS exposure, and application authorization as separate diagnostic questions.
The CORS credential and response-field guidance covers these interactions. A preflight normally excludes credentials under the standard model, even when the proposed application request is credentialed. Middleware that requires a logged-in session for every OPTIONS request can therefore block the negotiation before the authorized application request is evaluated.
A Failed Preflight and a Failed API Call Are Different
A failed preflight can stop the browser from sending the proposed application request. In that case the API route may have no corresponding application operation in its logs, while the gateway records OPTIONS. Start diagnosis by determining which exchange occurred. A generic CORS error in the console does not by itself identify whether routing, field policy, credentials, or the actual response caused the problem.
If the application request did reach the server, inspect its own status and CORS response fields. A service can return a useful error body that browser JavaScript cannot read because the error response omitted origin permission. Apply the intended CORS policy consistently to supported success and error responses while preserving normal API authorization. Do not turn every failure into an origin allowlist change.
An OPTIONS request is not always a CORS preflight. HTTP defines OPTIONS more generally as a request about communication options for a target resource. The HTTP OPTIONS semantics and the presence of the CORS request fields help distinguish a browser preflight from a manually issued OPTIONS request or another infrastructure check. Diagnose the request that is actually present rather than its method name alone.
Preflight Caching Has Its Own Lifecycle
Browsers can cache a successful preflight permission according to the applicable rules, including Access-Control-Max-Age and implementation limits. That cache is distinct from ordinary cached application response content. It can explain why a later request appears without a new OPTIONS exchange. The absence of a preflight in one trace does not prove that the request would never require one.
Caching scope also depends on request context, origin, target, method, and field permissions. A successful check for one route or field set is not blanket approval for every operation at the host. When debugging, record the proposed method and request fields along with the target URL. Comparing traces without those details can make normal policy differences look inconsistent.
A server that returns different origin permissions for different callers should account for intermediary cache behavior. The HTTP cache selection rules explain how response variation must be represented to prevent inappropriate reuse. Where an application response varies by Origin, configure the relevant cache variation rather than allowing one caller’s origin declaration to be reused indiscriminately for another.
Debug the Exchange from Origin to Application
Begin with the calling page’s full origin and the final API target. Check whether a redirect or gateway routes OPTIONS differently from the application method. Compare the proposed method and fields with the server’s explicit policy. Then inspect whether the actual request arrived and whether its response includes the expected CORS fields. This sequence locates the failure without weakening the policy indiscriminately.
A command-line client can help inspect an HTTP response, but it does not reproduce browser CORS enforcement by itself. A request succeeding from a backend process proves only that this process obtained a response under its own network and credential context. The browser still evaluates origin rules. Changing the client to a mode that hides the response does not create permission to read protected response content.
Keep diagnostics sanitized. Authorization values and cookies should not be pasted into shared traces. Usually the field names, origin, route, method, status, and permission-field values are enough to explain a CORS mismatch. If the application touches personal records, capture only the minimum content necessary for the authorized investigation and keep that capture within the appropriate access boundary.
Browser Automation Still Follows the Origin Model
Scrapeless Agent Browser provides a browser environment for automated navigation and interaction. It does not change the target page’s cross-origin application contract. The Agent Browser overview describes the browser capability, while the page and API owners remain responsible for the origin policy and the permissions granted to the caller.Keep the browser control connection separate from JavaScript executing inside the target page. An automation client reaching a cloud browser and a page script reaching a cross-origin API are different network interactions. Success in the control channel cannot prove that the page’s API call passed CORS. Observe the target request and its corresponding response when explaining what the page could access.
The Fetch request workflow is related reading for HTTP clients, and Scrapeless pricing covers browser service usage. For an authorized test, define the expected origin, operation, and visible page result. A passing browser observation should confirm both the policy exchange and the resulting application behavior, rather than stopping at an OPTIONS status.
Conclusion
A preflight evaluates a specific proposed cross-origin operation before certain browser requests proceed. Inspect the calling origin, method, field names, credential mode, and both responses. Keep browser permission checks separate from API authorization, and diagnose the policy at the component that owns the failed exchange.
Build Your Web Data Workflow
Use Agent Browser to observe permitted page workflows and verify cross-origin behavior at the actual target request boundary.
Sign up today and get $5 in free credit — no credit card required.
Claim Your $5 Credit →FAQ
Does every cross-origin request need preflight?
Not every cross-origin request needs preflight. The browser evaluates the method, request fields, their values, and the applicable Fetch rules. A request without preflight still needs the appropriate CORS response permission for JavaScript to access its cross-origin response.
Does HTTP 200 on OPTIONS prove CORS is correct?
HTTP 200 on OPTIONS does not prove CORS is correct. The browser also checks the allowed origin, method, fields, and credential requirements. The actual application response must satisfy its own CORS checks after the preliminary exchange succeeds.
Is CORS an authentication system?
CORS is not an authentication system. It governs cross-origin access by browser code. The API must separately validate credentials and enforce resource permissions, including for clients that do not implement browser origin-policy checks.
Why does an API work from a backend but fail in a browser?
An API can work from a backend while failing in a browser because browser JavaScript must satisfy the same-origin and CORS rules. Also compare credentials, final URLs, and request fields; the two clients may not be sending equivalent requests.
Why is there no OPTIONS request in a later network trace?
A later trace can omit OPTIONS because the request does not require preflight or a valid preflight permission is already cached. Compare the complete request context before drawing a conclusion. Application-response caching and preflight permission caching are different mechanisms.