ubiquity / pay.ubq.fi

Generate and claim spender permits (EIP-2612)
https://pay.ubq.fi
8 stars 29 forks source link

Cloudflare CORS issues #200

Open rndquu opened 4 months ago

rndquu commented 4 months ago

Original comment

We've updated DNS records and now https://pay.ubq.fi/ returns CORS related errors when accessing RPCs behind Cloudflare, we should for these errors:

Screenshot 2024-03-13 at 10 10 14
0x4007 commented 4 months ago

I guess the solution would be for some developer to make their own RPC endpoint on their own Cloudflare account and then fix CORs. Or make some type of proxy just to get around CORs

EresDev commented 3 months ago

/start

ubiquibot[bot] commented 3 months ago

DeadlineFri, Apr 5, 8:16 PM UTC
Registered Wallet 0xE7a9fdf596D869AF34a130fa9607178B2B9800D9
Tips:
EresDev commented 3 months ago

I guess the solution would be for some developer to make their own RPC endpoint on their own Cloudflare account and then fix CORs. Or make some type of proxy just to get around CORs

I have tried to reproduce it. I have created an Ethereum web3 gateway on Cloudflare and it worked well. It appears to be so solid that I couldn't break it easily. No CORS problem. It comes with appropriate headers to not have a CORS issue.

The problem above is 530 error combined with Error 1016 of Cloudflare, meaning a missing CNAME record.

My theory is during the changing of DNS, it somehow messed up the configs related to web3 gateway. Or, the RPC is very old and Cloudflare has changed the way it handles the web3 gateways now.

I suggest recreating the RPC using the steps below.

After making these changes, it is possible DNS will not resolve soon, so you will have to wait for that. For me, clearing my OS DNS cache and restarting my internet router gave me instant result.

0x4007 commented 3 months ago

For me, clearing my OS DNS cache and restarting my internet router

This is something I didn't try. I'll have to try later and confirm it!

Does rpc.ubq.fi work for you?

image

EresDev commented 3 months ago

Does rpc.ubq.fi work for you?

No, this didn't work but I see all subdomains are trying to point to pages, whatever you write

rpc.ubq.fiis trying to get to rpc-ubq-fi.pages.dev xyz.ubq.fi trying to get to xyz-ubq-fi.pages.dev

This is not the case for the example domain I have set up in Cloudflare.

Something is taking precedence over the cname record for your web3 gateway. It could be another CNAME record, or maybe page rules or both combined.

I see easy way is to give me access to cloudflare account to troubleshoot. If this is not possible, you can help me along. If you want to go with the second option, I need a screenshot of two things.

  1. Did you setup any Rules in Websites > ubq.fi > Rules (page or rules or redirect rules, other any rules that you set) I need a screenshot of these rules
  2. DNS records

I hope you are not using load balancers or things like that.

0x4007 commented 3 months ago

I wrote a worker that explains the behavior you're explaining. I know what it is and I'll need to spend some time more carefully configuring things. Thanks for your research!