export default {
async fetch(request, env, ctx) {
let response = await fetch(request)
// Check if the request URL ends with "test.html"
// Create a new response with the same content but a different URL
const newUrl = request.url.replace('/test.html', '/rewrite.html')
console.log(newUrl)
response = new Response(response.body, {
status: 301, // Redirect status code
headers: {
...response.headers,
'Location': newUrl
}
})
return response
},
};
export default {
async fetch(request, env, ctx) {
let response = await fetch(request)
// Check if the request URL ends with "test.html"
// Create a new response with the same content but a different URL
const newUrl = request.url.replace('/test.html', '/rewrite.html')
console.log(newUrl)
response = new Response(response.body, {
status: 301, // Redirect status code
headers: {
...response.headers,
'Location': newUrl
}
})
return response
},
};