Connection time out: Error Code 522

I am deploying my first next js app and trying to connect it with a custom domain from cloudflare. I deployed it using cloudflare pages which all works fine. However, once I connected a custom domain to it, I get a connection timed out: error code 522 when trying to open it on the custom domain. How do I fix this?
12 Replies
Chaika
Chaika8mo ago
Did you add the Custom Domain from the Pages Project Custom Domain tab?
Yatsz
YatszOP8mo ago
Yes
Chaika
Chaika8mo ago
What is the status of the domain under that tab?
Yatsz
YatszOP8mo ago
the status is active
Chaika
Chaika8mo ago
Did you add exactly the hostname you are using? for example, if you are trying to use www and your apex/root domain, both need to be Custom Domains under the Pages Project tab
Yatsz
YatszOP8mo ago
I might need some clarification on that so i added the domain to the custom domains tab in my project and then also added the www cname as well those are the two things i have done, is there anything else i need to configure?
Chaika
Chaika8mo ago
if you want the www to work, you need to add the www subdomain as another Pages Custom Domain as well
Yatsz
YatszOP8mo ago
hmm okay that fixed it but i have another question in that all my styling disappears when i open it with the custom domain from my next js app
Chaika
Chaika8mo ago
it works fine on the pages.dev?
Yatsz
YatszOP8mo ago
yea
Chaika
Chaika8mo ago
In your cloudflare website in the dashboard, go to Speed -> Optimization -> Content Optimization. Disable Rocket Loader, and disable Auto Minify under that same section for all types Magic Link: https://dash.cloudflare.com/?to=/:account/:zone/speed/optimization/content it could also be just cache if you had the old broken styling at some point in the past but iirc nextjs should use hashes for all of the assets in the filenames
Yatsz
YatszOP8mo ago
it was the cache just cleared it and it worked tysm
Want results from more Discord servers?
Add your server