-
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.
-
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.
- 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
-
Build your React application using
vite build
or any other method. -
Serve the build generated by vite inside
dist
directory usingnpm 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/");
});
- 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)