How to make worker respond a improper Content-Type?

I want to create a worker that only curl can read information, but browsers like Chrome cannot.
Throught this post I guess browsers needs to know what Content-Type the server is returned so browsers can render the content, so I’m thinking is there anyway to make the worker respond with improper Content-Type or not respond the Content-Type at all.

That wouldn’t really prevent browsers from “reading” the content. If nothing else, they will prompt the user with a save dialog.

What you probably want to do is filter for the user agent and only return content when curl was mentioned. Of course, you could still configure browsers to do that as well.

What is it you want to achieve? Generally speaking, that’s not really a Cloudflare related topic however.

When you use the option return 404 “Content”; in nginx, you will see this, so I want to copy this effect with a Cloudflare worker.

Snipaste_2022-10-28_01-56-42

The feature you mentioned simply returns a 404 with the given data and should not show the error you posted.

Anyhow, as I mentioned you best filter for the user agent and simply return a 404 when it’s not curl. For details on the implementation, I’d refer to StackOverflow or Reddit. On the other hand you could also simply use firewall rules and block requests which do not send a curl user agent.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.