Skip to main content

Command Palette

Search for a command to run...

Windows as Server with Cloudfare

Updated
โ€ข2 min read

How we ran bhasika locally

๐Ÿงฑ 1. Make sure your app is running locally

Start your backend:

http://localhost:3000

๐Ÿ‘‰ Test in browser first โ€” if this doesnโ€™t work, nothing else will.


๐Ÿ“ฅ 2. Install Cloudflared (Windows)

Download from:

  • cloudflared

Steps:

  1. Download .exe

  2. Rename to:

cloudflared.exe
  1. Move it to:
C:\cloudflared\

๐Ÿ”‘ 3. Login to Cloudflare

Open Command Prompt (as Administrator):

cd C:\cloudflared
cloudflared tunnel login

๐Ÿ‘‰ Browser opens โ†’ login โ†’ select your domain


๐Ÿ› ๏ธ 4. Create Tunnel

cloudflared tunnel create bhasika-server

๐Ÿ‘‰ This creates a credentials file automatically.


๐Ÿ“ 5. Create config file

Go to:

C:\Users\YOUR_USERNAME\.cloudflared\

Create file:

config.yml

Paste:

tunnel: bhasika-server
credentials-file: C:\Users\YOUR_USERNAME\.cloudflared\<tunnel-id>.json

ingress:
  - hostname: api.yourdomain.com
    service: http://localhost:3000
  - service: http_status:404

๐Ÿ‘‰ Replace:

  • YOUR_USERNAME

  • <tunnel-id>

  • yourdomain.com


๐ŸŒ 6. Connect domain to your local server

Run:

cloudflared tunnel route dns bhasika-server api.yourdomain.com

๐Ÿ‘‰ This automatically creates DNS in Cloudflare


โ–ถ๏ธ 7. Start your tunnel

cloudflared tunnel run bhasika-server

Now open:

https://api.yourdomain.com

๐Ÿ”ฅ Your home laptop is LIVE.


๐Ÿ”„ 8. Auto-start on Windows (VERY IMPORTANT)

Otherwise your server dies every restart.

Option A (Simple):

Create a .bat file:

cd C:\cloudflared
cloudflared tunnel run bhasika-server

Put it in:

Startup folder:
Win + R โ†’ shell:startup

Option B (Better): Task Scheduler

  1. Open Task Scheduler

  2. Create Task

  3. Trigger โ†’ At Startup

  4. Action โ†’ Start Program:

C:\cloudflared\cloudflared.exe

Arguments:

tunnel run bhasika-server

๐Ÿง  Pro Setup (Highly Recommended for You)

Since you're building something serious:

Run multiple services

Example:

ingress:
  - hostname: api.yourdomain.com
    service: http://localhost:3000
  - hostname: app.yourdomain.com
    service: http://localhost:5173