17 lines
506 B
TypeScript
17 lines
506 B
TypeScript
import { getHeader, getRequestHost, defineEventHandler } from "h3";
|
|
|
|
export default defineEventHandler((event) => {
|
|
const host =
|
|
(getHeader(event, "host") || getRequestHost(event)).toString() || "";
|
|
const baseDomain = process.env.BASE_DOMAIN || ".onstove.com";
|
|
const isGameAliasExtractable = host.includes(baseDomain);
|
|
|
|
if (isGameAliasExtractable) {
|
|
const gameAlias = host.split(".")[0];
|
|
|
|
if (gameAlias && gameAlias !== "www") {
|
|
event.context.gameAlias = gameAlias;
|
|
}
|
|
}
|
|
});
|