-
-
Save sbennettmarqeta/d3c7e9fe66bedc6d83c4b08fb42169c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default async (request, context) => { | |
const url = request?.url; | |
if (/\/(static|_next|fonts)/gi.test(url)) { | |
return; | |
} | |
const forwardedFor = request.headers.get('X-Forwarded-For'); | |
context.log(`Country toggle function invoked ${context.geo.country.code} // ${context.geo.city} // ${forwardedFor}`); | |
const countryCode = context?.geo?.country?.code; | |
context.cookies.set({ name: 'mqCountryToggle', value: countryCode ? countryCode : 'US' }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment