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
lookie029mo 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-Jak39mo 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
lookie029mo 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
lookie029mo 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
lookie029mo 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
More Posts
Calling Third Party API from CloudFlare WorkerHi Devs. I need some help. I’m trying to call a third api that is using a non-standard port (8388). Migrated website but getting DNS_PROBE_FINISHED_NXDOMAINLast night I brought one of my existing domains (gotilde.com) under CF and added one of the sample aGithub integration after deploying with WranglerI deployed directly with wrangler, and would now like to deploy preview branches automatically. CloWe encountered an internal error. Please try again. (Code: 10001)Hi, I’ve just created some R2 buckets, but when I go to the bucket settings in the dashboard and tryIs possible to run migrations in Pages build command?I'm not sure what is the right flow to run D1 migrations... If I understand it correctly so far, youneed to upload video on cloudflare stream using laravelHi need to upload video on cloudflare stream using laravel My laravel code is: public function hanIs there a way to connect to D1 locally in, say, a Nuxt.js app in dev mode?I tried running `wrangler pages dev --proxy [nuxt dev server port] -- pnpm dev` but the `context.cloCloudflare Pages logs when using `wrangler pages deploy`Hi, I'm using `wranger pages deploy` to deploy a Sveltekit project. However, I get a failed deploymeWanted to know that what changed on ssl of multi-level subdomain than beforeiirc the SSL by cloudflare on multi-level subdomain (to use cloudflare secure proxy) was possible beLoad Balancinglets assume i have 2 servers one which has capacity of 100TB data and 1Tb Ram and 64Amd cores with 1