Untitled
unknown
plain_text
2 years ago
405 B
6
Indexable
##server/middleware/wwwRedirects.js
export default defineEventHandler((event) => {
const config = useRuntimeConfig();
const host = getRequestHeader(event, "host");
const url = event.node.req.url;
const env = config.enviroment;
if (env === "production" && host.startsWith("www.")) {
const nonWWWHost = host.substring(4);
sendRedirect(event, `https://${nonWWWHost}${url}`, 301);
}
});
Editor is loading...
Leave a Comment