diff --git a/.netlify/state.json b/.netlify/state.json index 636109c..1215e69 100644 --- a/.netlify/state.json +++ b/.netlify/state.json @@ -1,16 +1,16 @@ { "geolocation": { "data": { - "city": "Abyhoj", + "city": "Ishøj", "country": { "code": "DK", "name": "Denmark" }, "subdivision": { - "code": "82", - "name": "Central Jutland" + "code": "84", + "name": "Capital Region" } }, - "timestamp": 1666946135442 + "timestamp": 1667215722359 } } \ No newline at end of file diff --git a/netlify/edge-functions/split-test.ts b/netlify/edge-functions/split-test.ts index de8a341..9f8f978 100644 --- a/netlify/edge-functions/split-test.ts +++ b/netlify/edge-functions/split-test.ts @@ -7,6 +7,13 @@ export default async (request: Request, context: any) => { return context.next(); } + const requestUrl = new URL(request.url); + + console.log("INC URLS: ", requestUrl.origin, buckets[0].url) + if (requestUrl.origin === buckets[0].url) { + return context.next(); + } + //Ensure weighting adds up to 1 const totalWeighting = buckets.reduce( (tot: any, bucket: any) => tot + bucket.weight, @@ -17,8 +24,6 @@ export default async (request: Request, context: any) => { //Set the cookie name of the bucket const cookieName = "netlify-split-test"; - const requestUrl = new URL(request.url); - // Get the bucket from the cookie let bucket = context.cookies.get(cookieName); let hasBucket = !!bucket; @@ -54,7 +59,7 @@ export default async (request: Request, context: any) => { //Generate full proxy url const url = `${bucket}${requestUrl.pathname}`; - context.log({ url }); + context.log("Proxy-URL:", { url }); //Set cookie if new bucket has been set if (!hasBucket) { context.cookies.delete(cookieName);