Skip to content

Commit

Permalink
Let caddy handle https redirection instead of doing it by ourselves (#7)
Browse files Browse the repository at this point in the history
Caddy automatically redirects to https, if the domain name qualifies.

Some hosting services already lays a front layer with https, which the current configuration would break.

https://caddyserver.com/docs/automatic-https#overview
  • Loading branch information
xuhdev authored Jan 5, 2025
1 parent e74744d commit d4dae6c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
5 changes: 1 addition & 4 deletions Caddyfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
admin off
}

{$DOMAIN:localhost}:80 {
redir https://{host}{uri} permanent
}

{$DOMAIN:localhost}:80,
{$DOMAIN:localhost}:443 {
redir /abc https://example.com
@snapshot path_regexp ^/snapshot/(\d\d\d\d-\d\d-\d\d)/(.*)$
Expand Down
10 changes: 0 additions & 10 deletions index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ const domain = "localhost" as const;
const delpaGitHubRawBaseUrl =
"https://raw.githubusercontent.com/delpa-org" as const;

test("Redirect http to https", async () => {
const hostAddress = `http://${domain}:3000`;
const response = await fetch(`${hostAddress}/some/path`, {
redirect: "manual",
});

expect(response.status).toBe(301);
expect(response.headers.get("location")).toBe(`https://${domain}/some/path`);
});

describe("/snapshot", () => {
const hostAddress = `https://${domain}:3001`;
const snapshotFirstPathComp = "snapshot" as const;
Expand Down

0 comments on commit d4dae6c

Please sign in to comment.