Skip to content

Commit

Permalink
fix: add handlers for the authourl addition. Closes #225 (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfisher authored Sep 22, 2024
1 parent 243d60c commit 8ed334b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/handlers/gatsby_index_redirect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ export const handler = async (event) => {
const request = event.Records[0].cf.request;
const { uri } = request;

if (uri.endsWith('/')) {
if (uri.endsWith('%7Bauthourl%7D')) {
// this is dealing with a bunch of the 404 errors we see where there's a
// {authourl} appended to the end of the request - just remove this
request.uri = uri.replace('%7Bauthourl%7D', '');
}

if (uri.endsWith('{authourl}')) {
// this is dealing with a bunch of the 404 errors we see where there's a
// {authourl} appended to the end of the request - just remove this
request.uri = uri.replace('{authourl}', '');
}

if (request.uri.endsWith('/')) {
request.uri += 'index.html';
} else if (!uri.includes('.')) {
} else if (!request.uri.includes('.')) {
request.uri += '/index.html';
}

return request;
};

0 comments on commit 8ed334b

Please sign in to comment.