Skip to content

Instantly share code, notes, and snippets.

@bridgpal
Created November 26, 2024 17:18
Show Gist options
  • Save bridgpal/1f8c99b136a364d089804fad9ddb4522 to your computer and use it in GitHub Desktop.
Save bridgpal/1f8c99b136a364d089804fad9ddb4522 to your computer and use it in GitHub Desktop.
import type { Context, Config } from "@netlify/edge-functions";
export default async (request: Request, context: Context) => {
const FIRST_VISIT_COOKIE = "has-visited";
const hasVisited = context.cookies.get(FIRST_VISIT_COOKIE);
if (!hasVisited) {
context.cookies.set({
name: FIRST_VISIT_COOKIE,
value: "true",
path: "/",
});
return new URL("/en/insights", request.url);
}
return new URL("/en/support/community", request.url);
}
export const config: Config = {
path: "/testing",
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment