Skip to content

Commit 614ec82

Browse files
authored
Redirect www.lit.dev to lit.dev (#587)
1 parent d4afb19 commit 614ec82

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/lit-dev-server/src/middleware/redirect-middleware.ts

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import type Koa from 'koa';
1111
* Creates a Koa middleware that performs lit.dev redirection logic.
1212
*/
1313
export const redirectMiddleware = (): Koa.Middleware => async (ctx, next) => {
14+
if (ctx.host === 'www.lit.dev') {
15+
const url = new URL(ctx.URL);
16+
url.hostname = 'lit.dev';
17+
ctx.status = 301;
18+
ctx.redirect(url.href);
19+
return;
20+
}
1421
// If there would be multiple redirects, resolve them all here so that we
1522
// serve just one HTTP redirect instead of a chain.
1623
let path = ctx.path;

0 commit comments

Comments
 (0)