Redirect from root to www not working
Hi,
I have following rule. Page is accessible via https:/www.mydoman.com but no via https:/mydoman.com. I got:
ERR_NAME_NOT_RESOLVED
Here is my DNS config. I use pythonanywhere.com as hosting my Djnago app
12 Replies
Hi 👋
You also need to add a DNS record for your apex and make sure it's proxied. If your only goal with mydomain.com is to redirect to www.mydomain.com, you can create an AAAA record and use
100::
as the value. By default it would be proxied, and as soon as DNS is propagated you should be goodHi @DaniFoldi . Thanks for you answer.
Pythonanywhere.com not provide IP adress to set for apex domain 😦 They use CNAME. Is that AAAA record will be ok?
with 100::, Cloudflare will consider the record as originless, so if you don't redirect/etc/handle the request, your visitors will see a 522.
With your rule in the first screenshot, https requests will all be redirected. You might want to also include http:// requests
Otherwise if they gave you a CNAME for the root, Cloudflare will flatten it for you if you set a CNAME record on the apex (meaning it will serve A/AAAA records for any queries, not the CNAME)
don't understand that 😛 Correct me if I wrong but all what I need is add rule to redirect also http and it will works if DNS propagate. Yes?
yes
It works! You are the best! Thanks a lot!
glad it's working for you :MeowHeartCloudflare:
Now i facing:
Forbidden (403)
CSRF verification failed. Request aborted.
When try to log, but maybe is some Django issue
hmm, could be caused by the redirect, but this is coming from your backend
i think proxy form cloudflare remove some headers
Stack Overflow
Django Cloudflare Proxy "CSRF Verification Failed"
I'm trying to proxy my Django App through Cloudflare via workers.
The setup is like so:
example.com/app/* forwards to my Django site
~everything else~ forwards to my Webflow site
So far that part is
the bug ended up being in the Cloudflare proxy worker code--
the correct Cloudflare proxy worker was
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
let url = new URL(request.url);
// where we're proxying to
url.hostname = "fluent-spring.uc.r.appspot.com";
const newRequest = new Request(url.href, request);
newRequest.headers.set("Referer", url.href);
return await fetch(newRequest);
}
not sure where I should change thatr
Fixed
On Django side
Thanks a lot @DaniFoldi