Can't modify immutable headers seen while trying to navigate into different paths of the website

So what I am basically doing is we have a react application and a webflow app. We are trying to keep the home page and some of the paths like /blog, /pricing from the webflow. The webflow application is working fine on the home page or on / path but issue occurs when I try to navigate to other paths of the webflow application. The application works fine with react application and path routing also works fine, But issue is seen with webflow application. I though it was the issue with webflow so I have the paid plan and the custom domain navigated to my domain. But still immutable headers is seen. When I removed this message then 404 cloudflare page is seen when I try to navigate into it,
5 Replies
lookie02
lookie02OP16mo ago
This is the code snippet addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const url = new URL(request.url) // Paths that should be routed to Webflow const webflowPaths = ['/pricing', '/blog', '/products'] if (url.pathname === '/') { // Serve the Webflow site for the root path return fetch('https://webflow.application', request) } else if (webflowPaths.some(path => url.pathname.startsWith(path))) { // Modify 'host' header to your Webflow site for other Webflow paths request.headers.set('Host', 'web-flow.application') return fetch(request) } else { // If not a Webflow path, route to your React app const reactAppUrl = 'https://react.application + url.pathname return fetch(reactAppUrl, request) } }
Cyb3r-Jak3
Cyb3r-Jak316mo ago
You need to clone the request to set new headers. See https://developers.cloudflare.com/workers/examples/alter-headers/ but instead of response it will be request
Alter headers · Cloudflare Workers docs
You can also use the custom-headers-example template to deploy this code to your custom domain.
lookie02
lookie02OP16mo ago
The issue seems revolved when I run it through the worker site but when I run it through custom domain. It shows 502 bad gateway error. I dont know what is going wrong. https://myordr-webflow.asterdio-inc2022.workers.dev/ This is my worker site and everything is going right, giving me 200 status. But when I go through the same worker in custom domain. https://worker.myordr.com/. Its not working and 301 redirecting it to the webflow application which i do not want.
myordr | The Guest Experience Software for Hotels and Resorts
The ultimate Guest Management platform - Multi-Channel Contactless Ordering, Guest Request and Fulfilment, Upsells & much more!
myordr | The Guest Experience Software for Hotels and Resorts
The ultimate Guest Management platform - Multi-Channel Contactless Ordering, Guest Request and Fulfilment, Upsells & much more!
lookie02
lookie02OP16mo ago
When I curl for the sub domain linked with the worker, it redirects me to the webflow site But when I curl the same worker site, it gives me this result
No description
No description
lookie02
lookie02OP16mo ago
I don't know there are two different status for the same worker ha ha my subdomain throws 301 redirect and the worker throws 200 status and is working fine
Want results from more Discord servers?
Add your server