A minimal CloudFront function for static sites.
- Routing Logic:
- Requests without an extension are rewritten:
/about
→/about.html
- Unmatched cases default to
/index.html
- Requests with an extension (e.g.,
/sitemap.xml
) remain unchanged.
- Requests without an extension are rewritten:
To ensure proper URL rewriting, configure Astro to output files (not directories) by setting the following in your astro.config.mjs
export default defineConfig({
build: {
format: 'file',
},
});