Untitled

 avatar
unknown
plain_text
2 years ago
379 B
4
Indexable
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