// troubleshooting guide · aws cloudfront

CloudFront React App 403/404 on Page Refresh

Status
Workaround available
platforms:
React, Vue, Angular, Next.js static export
updated:
November 17, 2026
reports:
5
Method
how we research
Share

RUNBOOK · aws-cloudfront/spa-403-on-refresh3 FIXES

// quick answer

Refreshing a client-side route (like /dashboard) on an S3 + CloudFront SPA returns 403 because no S3 object exists at that path. Map 403 and 404 to /index.html with status 200, or rewrite routes with a CloudFront Function.

Most likely fix: Add custom error responses

How to fix it

// try these in order, the most common fix is first

  1. FIX 1Add custom error responses

    1. 01Open the distribution > Error pages > Create custom error response
    2. 02HTTP error code 403, Customize error response Yes, Response page path /index.html, HTTP response code 200
    3. 03Repeat for 404
    4. 04Set Error caching minimum TTL low (e.g. 0-10 seconds) while testing
    Did this fix it?
  2. FIX 2Rewrite routes with a CloudFront Function

    1. 01Open CloudFront > Functions > Create function
    2. 02Write a viewer-request handler that sets request.uri to /index.html when the path has no file extension
    3. 03Publish it and associate it with the default behavior as Viewer request
    Did this fix it?
  3. FIX 3Keep real 404s for API or asset paths

    1. 01Put APIs on a separate cache behavior or origin
    2. 02Prefer the CloudFront Function approach, since custom error responses apply to the whole distribution
    Did this fix it?

Symptoms

Home page loads, but refreshing or opening a deep link returns AccessDenied XML or a 404.

Why it happens

  • C-01S3 has no object for client-side routes and returns 403 (or 404 with ListBucket)
  • C-02No custom error response or URL rewrite configured
  • C-03Error caching TTL keeps serving the old error after a fix

// this guide also covers

  • cloudfront react refresh 403
  • cloudfront spa 404 on refresh
  • s3 cloudfront react router
  • cloudfront single page application routing

Still not working?

If AWS CloudFront keeps failing, you're not alone. See every AWS CloudFront problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us

Watch AWS CloudFront Get an email when its price changes, it has an outage, or we publish a new fix. No spam.

Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other AWS CloudFront errors

All 12 AWS CloudFront errors and fixes →