feat: www <-> non-www redirection
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
forceSSLOffApplication,
|
||||
forceSSLOnApplication,
|
||||
reloadHaproxy,
|
||||
removeWwwRedirection,
|
||||
setWwwRedirection,
|
||||
startCoolifyProxy
|
||||
} from '$lib/haproxy';
|
||||
import { letsEncrypt } from '$lib/letsencrypt';
|
||||
@@ -45,9 +47,10 @@ export const del: RequestHandler = async (event) => {
|
||||
const { fqdn } = await event.request.json();
|
||||
|
||||
try {
|
||||
await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
|
||||
const domain = getDomain(fqdn);
|
||||
await configureCoolifyProxyOff({ domain });
|
||||
await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
|
||||
await configureCoolifyProxyOff(fqdn);
|
||||
await removeWwwRedirection(domain);
|
||||
return {
|
||||
status: 201
|
||||
};
|
||||
@@ -77,9 +80,10 @@ export const post: RequestHandler = async (event) => {
|
||||
await db.prisma.setting.update({ where: { id }, data: { isRegistrationEnabled } });
|
||||
}
|
||||
if (oldFqdn && oldFqdn !== fqdn) {
|
||||
const oldDomain = getDomain(oldFqdn);
|
||||
if (oldFqdn) {
|
||||
await configureCoolifyProxyOff({ domain: oldDomain });
|
||||
const oldDomain = getDomain(oldFqdn);
|
||||
await configureCoolifyProxyOff(oldFqdn);
|
||||
await removeWwwRedirection(oldDomain);
|
||||
}
|
||||
}
|
||||
if (fqdn) {
|
||||
@@ -88,7 +92,8 @@ export const post: RequestHandler = async (event) => {
|
||||
const domain = getDomain(fqdn);
|
||||
const isHttps = fqdn.startsWith('https://');
|
||||
if (domain) {
|
||||
await configureCoolifyProxyOn({ domain });
|
||||
await configureCoolifyProxyOn(fqdn);
|
||||
await setWwwRedirection(fqdn);
|
||||
if (isHttps && !dev) {
|
||||
await letsEncrypt({ domain, isCoolify: true });
|
||||
await forceSSLOnApplication({ domain });
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<div class="px-4 sm:px-6">
|
||||
<div class="flex space-x-4 py-4 px-4">
|
||||
<p class="pt-2 text-base font-bold text-stone-100">Domain (FQDN)</p>
|
||||
<div class="justify-center text-center">
|
||||
<div class="justify-center">
|
||||
<input
|
||||
bind:value={fqdn}
|
||||
readonly={!$session.isAdmin || isFqdnSet}
|
||||
|
||||
Reference in New Issue
Block a user