diff --git a/server/index.ts b/server/index.ts index 6023581..92648e9 100644 --- a/server/index.ts +++ b/server/index.ts @@ -19,6 +19,13 @@ type ContextEnv = { Bindings: RuntimeEnv }; const server = new Hono(); +server.use("*", (context, next) => { + let url = new URL(context.req.url); + if (!url.origin.includes("www.")) return next(); + url.hostname = url.hostname.slice(4); + return c.redirect(url.href, 302); +}); + server.use("/write", (context, next) => { let { WRITE_PASSWORD } = EnvSchema.parse(context.env); return basicAuth({ username: "sergiodxa", password: WRITE_PASSWORD })(