Skip to content

portsicle/portsicle-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portscile Client

  • Portsicle is a Free and Open-source platform to expose local web servers online.

  • Portsicle client allows you to use the Portsicle Server via CLI.

Installation

  • Install the latest release for your operating system.

  • For Linux, you may need to give executeable permission to the binary chmod +x ./portsicle.

  • For Windows, the portsicle_win_x64.exe file is directly executable via CLI.

Client Usage

  • Use the CLI to run the client:
./portsicle http -p 3000
  • for windows:
./portsicle_win_x64.exe http -p 3000

note that 3000 is the port of your local server which you want to expose on public network.

  • for more help:
./portsicle --help

Guide

React + Vite

  1. Build your React application using vite build or any other method.

  2. Serve the build generated by vite inside dist directory using npm run preview.

  • Custom Script Example (use only if npm run preview doesn't work):
// dist/script.js
import { createRequire as t } from "node:module";
const e = t(import.meta.url)("http"),
  r = t(import.meta.url)("fs/promises"),
  a = t(import.meta.url)("path"),
  o = {
    ".html": "text/html",
    ".css": "text/css",
    ".js": "application/javascript",
  };
e.createServer(async (t, e) => {
  const n = "/" === t.url ? "/index.html" : t.url,
    i = a.join("./", n);
  try {
    const t = await r.readFile(i),
      n = a.extname(i);
    e.writeHead(200, { "Content-Type": o[n] || "application/octet-stream" }),
      e.end(t);
  } catch (t) {
    e.writeHead(404), e.end("File not found");
  }
}).listen(3e3, () => {
  console.log("Server running at http://localhost:3000/");
});
  1. With this minimal setup your build will be served locally, Now run the portsicle client and mention the port on which the build is running (3000 in this case).
./portsicle http -p 3000

Similar approach can be applied for Simple Node HTML servers as well as other meta Frameworks (Vue, Svelte, etc)