Cyb3r-Jak3 / cf-example-cors-application

Example for CORs on two sites using Cloudflare access

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cloudflare CORS ACCESS

Example of how to use CORS with Cloudflare access to pass credentials to a backend. Replace all .community.cyberjake.xyz with your domain.

Need the following:

Cloudflare Policies:

  • Cloudflare CORS policy
  • Cloudflare Access Application

Backend:

Cloudflare tunnel token with public hostnames as shown below. Cloudflare Tunnel Public Hostnames

Edit the cors settings in backend/index.js to match your origin.

Frontend:

Edit the server_name in frontend/nginx.conf to match your domain.

Running:

docker compose up --build

Wait for the tunnel to connect and then visit https://<your domain>/ to see the frontend and watch the console for the response from the backend.

Demo

View the demo at https://frontend.community.cyberjake.xyz/.

Demo Notes

  • It does require to verify with an email address to access the site.
  • I am able to see emails that sign up, so please don't use any sensitive information. You can use a temporary email service like Temp Mail to get a temporary email address.

About

Example for CORs on two sites using Cloudflare access

License:MIT License


Languages

Language:JavaScript 67.8%Language:Dockerfile 32.2%