Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukebussey/c3541d0fb9761af44fbd15c663d1b167 to your computer and use it in GitHub Desktop.
Save lukebussey/c3541d0fb9761af44fbd15c663d1b167 to your computer and use it in GitHub Desktop.
sub vcl_recv {
if (req.http.host == "domain.com" && req.url.path == "/user") {
error 601 "user";
}
}
sub vcl_error {
if (obj.status == 601) {
set obj.http.Content-Type = "text/json";
set obj.status = 200;
if (req.http.Origin ~ "localhost|domain\.com") {
set obj.http.Access-Control-Allow-Origin = req.http.Origin;
set obj.http.Access-Control-Allow-Credentials = "true";
synthetic {"{
"country": ""} client.geo.country_code {"""} if (<UserId>, {",
"identifier": ""} regsub(digest.hmac_sha256("<KEY>", <UserId>), "^0x","") {"""}, "") {"
}"};
} else {
synthetic {"{}"};
}
return(deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment