Skip to content

Commit 4549938

Browse files
authored
fix SPA routing (#218)
1 parent 27eb558 commit 4549938

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cloudformation/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,15 @@ Resources:
849849
return request;
850850
}
851851
852-
// Rewrite paths for the SPA, excluding /api and files with extensions
853-
if (!uri.startsWith('/api') && !uri.includes('.')) {
854-
request.uri = '/index.html';
852+
// If the URI starts with /api/ and has a trailing slash, or includes a dot (is a file),
853+
// let it pass through without modification.
854+
// This ensures paths like /api/v1/data or /some/image.png are not rewritten.
855+
if (uri.startsWith('/api/') || uri.includes('.')) {
856+
return request;
855857
}
856858
859+
// Rewrite and all other non-file paths to index.html for the SPA.
860+
request.uri = '/index.html';
857861
return request;
858862
}
859863

0 commit comments

Comments
 (0)