Skip to content

Commit

Permalink
fix: redirect should work locally and in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuebert committed May 30, 2024
1 parent b04e154 commit d002ad6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ function testPaths() {
// testPaths()

const serveHtmlWithFallbacks = async (res, parentDomain, subDomain, filePaths) => {
for (const filePath of filePaths) {
for (let filePath of filePaths) {
if (filePath.startsWith('redirect:')) {
filePath = process.env.ENV == 'dev' ?
path.join(parentDomain, subDomain, filePath.slice(9)) :
path.join('/', filePath.slice(9))
res.redirect(302, path);
res.redirect(302, filePath);
return;
}
const fullPath = path.join(parentDomain, subDomain, filePath);
Expand Down
1 change: 1 addition & 0 deletions tests/server_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Server Functionality Tests', function() {
it('should redirect /a-directory to /a-directory/ if /a-directory.html does not exist', async function() {
const response = await request(app).get(`/${bucketPath}/${subDomain}/a-directory`);
expect(response.status).to.equal(302);
console.log("LOC", response.headers.location)
expect(response.headers.location).to.equal(`${bucketPath}/${subDomain}/a-directory/`);
});

Expand Down

0 comments on commit d002ad6

Please sign in to comment.