Before a Sale, Check Your CSP Form-Action Checkout URL

Check your CSP form-action checkout URL before a sale. Trace staging submissions, inspect redirects, and distinguish forms from API calls and frames.

Published
Reading time
7 min read
Before a Sale, Check Your CSP Form-Action Checkout URL
On this page

A checkout form can look correct but fail when a shopper submits it because the page’s Content Security Policy (CSP) does not allow the form’s destination. Before changing payment providers or launching a sale, check the destination the browser actually submits to—not just the URL in a configuration file.

This guide walks through a staging test, explains redirects and third-party payment hosts, and separates form-action from other CSP directives. The current CSP specification and browser documentation were not available to consult for this article, and the example was not executed. Check the documentation and test the browsers your customers use before release.

Key Takeaways

  • form-action restricts where forms on a page may submit. A payment provider’s host may need to be allowed explicitly.
  • Inspect the actual submission in staging: JavaScript or a submit button can change the destination shown in the form’s original markup.
  • Test the complete redirect chain in target browsers. Do not assume that allowing the initial URL settles redirect behavior everywhere.
  • connect-src governs browser connections such as fetch; frame-src governs frames the page may load. Neither is a substitute for checking form-action.
  • Use dummy data and a provider-approved test environment. Never place real customer or payment data in test URLs.

What form-action checks

A CSP is delivered as part of a page’s response, commonly in a Content-Security-Policy HTTP header. The form-action directive limits the destinations to which forms in that document can submit. For example, this illustrative policy permits submissions to the page’s own origin and a fictional payment host:

Content-Security-Policy: form-action 'self' https://payments.example

The example is not a complete policy for an ecommerce site. Preserve your other required directives when updating a real header, and replace the fictional host with the exact staging or production origin you intend to permit. An origin includes the scheme, host, and port: allowing an HTTPS payment host does not automatically mean a different subdomain or port is allowed.

If a policy has no form-action directive, default-src does not serve as its fallback for form submissions. Also check for multiple enforced CSP headers: each enforced policy must allow the submission. A permissive directive in one policy cannot override a restriction in another.

Advertisement

Test the actual checkout destination in staging

Use a staging storefront and a payment-provider sandbox or test endpoint that is intended to receive test submissions. Coordinate with the provider before sending test requests. The following form is only a minimal illustration; the fictional host will not provide a working checkout. Replace it with your approved staging endpoint and fields before testing.

<form action="https://payments.example/checkout" method="post">
  <input type="hidden" name="order_reference" value="TEST-ORDER-001">
  <button type="submit">Continue to test checkout</button>
</form>

To trace your own checkout:

  1. Open the staging checkout page in a target browser. Use a test account and dummy order details only.
  2. Open Developer Tools before submitting. In the Network panel, enable preservation of the log across navigation. Open the Console as well.
  3. Inspect the form’s action and method in the Elements panel. Check the submit button for a formaction or formmethod override. Also account for application scripts that may change the form or handle the click.
  4. Submit once. In the Network panel, inspect the navigation request’s URL, method, status, and any redirect responses. Compare the first destination and later destinations with the origins your team and payment provider expect.
  5. If submission fails, check the Console for a CSP violation and inspect the checkout page’s response headers for enforced and report-only policies. A blocked request may not appear as a completed network request, so an empty network entry is not proof that no submission was attempted.
  6. After changing the policy, reload the page so the browser receives the updated policy, then repeat the test in the browsers you support.

Developer Tools can show sensitive request details and URLs. Keep logs and screenshots limited to dummy data; do not include real names, addresses, credentials, card details, or payment tokens. A POST request can also expose data in logs or request bodies, so use the provider’s designated test data and handle traces carefully.

Redirects and third-party payment hosts

A checkout might submit to your own server, to a payment provider, or through an intermediate service that redirects the browser. Record both the initial form destination and every subsequent destination in the staging trace. Confirm that each host and transition is expected with your application team or provider.

Browser handling of form-action across redirects needs particular care: do not assume identical behavior across every browser or infer success from one test. Consult current browser documentation and test the actual redirect chain in your supported browsers. If a redirect is blocked, investigate the policy, the destination, and the browser’s behavior before broadening the allowlist.

Redirect status also matters. For example, a 307 or 308 redirect preserves the request method and body; a 303 directs the client to retrieve the next resource. Never send sensitive form data through a redirect chain unless it is intended and approved. CSP is not a replacement for verifying the provider, protecting data in transit, or securing the server-side checkout flow.

Advertisement

Distinguish form submissions, API calls, and frames

Checkout behaviorCSP area to inspectWhat to verify
The page submits an HTML formform-actionThe actual submission destination and redirect behavior.
Page JavaScript calls a payment API with fetch or a similar browser connectionconnect-srcThe API origin the browser contacts. This is not a form submission merely because it starts from a checkout page.
The page embeds a payment-provider iframeframe-srcThe frame origin the embedding page is allowed to load. The provider’s framed document has its own applicable policy for actions it performs.

A checkout can use more than one of these mechanisms. For example, a page may load a provider’s frame and also call an API. Inspect the actual requests and the policy of the document performing each action rather than adding a payment domain to every directive by default. CSP in the shopper’s browser does not govern a server-to-server payment API call.

Common Mistakes

  • Checking only the markup. A submitter override or script can change the destination. Trace the actual submission.
  • Allowing only the storefront origin. 'self' will not match a separate payment-provider origin.
  • Editing connect-src for a blocked form. Determine whether the failing operation is a form navigation, a browser API request, or a frame load first.
  • Ignoring additional policies or report-only mode. Inspect all relevant response headers. A report-only policy can report violations without enforcing its restrictions.
  • Assuming staging and production match. They can use different hosts, redirects, headers, or payment-provider configurations.
  • Putting customer or payment data in a URL. URLs can be retained in browser history, server logs, analytics, and other traces. Use dummy data for tests and follow the provider’s integration requirements.

Pre-release Checklist

  • Confirm the intended production submission origin and any expected intermediate or provider hosts with the teams responsible for the integration.
  • Trace a complete staging checkout using dummy data and a provider-approved test endpoint. Inspect both the initial request and redirects.
  • Review the checkout page’s enforced CSP headers, including any additional policies added by infrastructure. Add only the destinations needed for the relevant directives.
  • Check the frame and API portions of the flow separately if the integration uses them.
  • Repeat the test in supported browsers, then verify the deployed production configuration without exposing real customer or payment data in URLs or diagnostic artifacts.
  • Keep a rollback plan and monitor checkout errors and CSP reports after release. Reports help identify failures but do not replace a successful end-to-end test.

Conclusion

A safe CSP change starts with the real checkout flow: identify who receives the form, inspect redirects, and allow only the destinations the integration needs. Test the whole path with dummy data before customers encounter it.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.