Expose localhost to the network using Cloudflare Tunnel



This content originally appeared on DEV Community and was authored by MUHAMMAD ARBAB ANJUM

Install cloudflared

Download from: https://github.com/cloudflare/cloudflared/releases

Change Dir

cd C:\cloudflared\

Login to Cloudflare

cloudflared tunnel login

Create tunnel

cloudflared tunnel create nextjs-tunnel

Route DNS

cloudflared tunnel route dns nextjs-tunnel test.myworkly.com

Create config.yml file in C:\cloudflared\config.yml

tunnel: nextjs-tunnel
credentials-file: C:\Users\%USERNAME%\.cloudflared\[your-tunnel-id].json

ingress:
  - hostname: test.domain.com
    service: http://localhost:3000
  - service: http_status:404

Quick Test

cloudflared tunnel --hostname test.domain.com --url http://localhost:3000

Run tunnel pointing directly to Next.js

cloudflared tunnel --config config.yml run nextjs-tunnel


This content originally appeared on DEV Community and was authored by MUHAMMAD ARBAB ANJUM