Skip to content

Commit

Permalink
Fixed improper generation of Cloudfront route redirects
Browse files Browse the repository at this point in the history
/admin and /studio (also /editor) need to handle both e.g. /admin and /admin/<subroute>

Non-builtin route matches are now exact-only, with a `$` at the end, to prevent fuzzy matches
that likely wouldn't point to anything.
  • Loading branch information
barankyle committed Jul 12, 2023
1 parent a2796ac commit a2d447c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/server-core/src/media/storageprovider/s3.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,22 @@ export class S3Provider implements StorageProviderInterface {
let routeRegex = ''
for (let route of routes)
if (route !== '/')
routeRegex +=
route === '/location' ||
route === '/auth' ||
route === '/admin' ||
route === '/editor' ||
route === '/studio' ||
route === '/capture'
? `^${route}/|`
: `^${route}|`
switch (route) {
case '/admin':
case '/editor':
case '/studio':
routeRegex += `^${route}$$|` // String.replace will convert this to a single $
routeRegex += `^${route}/|`
break
case '/location':
case '/auth':
case '/capture':
routeRegex += `^${route}/|`
break
default:
routeRegex += `^${route}$$|` // String.replace will convert this to a single $
break
}
if (routes.length > 0) routeRegex = routeRegex.slice(0, routeRegex.length - 1)
let publicRegex = ''
fs.readdirSync(path.join(appRootPath.path, 'packages', 'client', 'dist'), { withFileTypes: true }).forEach(
Expand Down

0 comments on commit a2d447c

Please sign in to comment.