Here is the revised message:
I have recently setup a Cloudflare worker with a custom domain. I am trying to redirect users to specific domains based on the current path (domain/code),then by searching for that code in Upstash Redis.
The issue I am facing is that even after updating the Redis key’s value, I keep getting redirected to the previously set value. I believe this is due to caching, but I am unable to figure out how to disable or bypass the caching.
My worker function is:
export default {
async fetch(request, env) {
return await handleRequest(request)
}
}
async function handleRequest(request) {
const url = new URL(request.url)
const path = url.pathname
const code = path.substring(1)
const redirect_url = await get_url(code)
return Response.redirect(redirect_url, 301)
}
async function get_url(code){
const response = await fetch(`https://upstash_redis.url`, {
headers: {
Authorization: "Bearer Token"
}
})
const data = await response.json()
console.log(data)
if(data.result != null ){
return data.result
}
else {
return "https://www.example_deafult.com"
}
}
Please let me know if you need any clarification or have any suggestions.