Skip to content

Commit 2279c06

Browse files
dorlugasigalCopilot
andcommitted
fix: detect npx symlink entry point without .js extension
When run via npx, the bin symlink is named 'termbeam' (no .js), so the endsWith('termbeam.js') check failed and the server never started. Use path.basename() to match both 'termbeam' and 'termbeam.js'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0e22963 commit 2279c06

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/server.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ function createTermBeamServer(overrides = {}) {
4747
res.setHeader('X-Frame-Options', 'DENY');
4848
res.setHeader('Referrer-Policy', 'no-referrer');
4949
res.setHeader('Cache-Control', 'no-store');
50-
res.setHeader('Content-Security-Policy', "default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; connect-src 'self' ws: wss:; font-src 'self' https://cdn.jsdelivr.net");
50+
res.setHeader(
51+
'Content-Security-Policy',
52+
"default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; connect-src 'self' ws: wss:; font-src 'self' https://cdn.jsdelivr.net",
53+
);
5154
next();
5255
});
5356

@@ -106,7 +109,8 @@ function createTermBeamServer(overrides = {}) {
106109
console.log('');
107110
console.log(` Beam your terminal to any device 📡 v${config.version}`);
108111
console.log('');
109-
const isLanReachable = config.host === '0.0.0.0' || config.host === '::' || config.host === ip;
112+
const isLanReachable =
113+
config.host === '0.0.0.0' || config.host === '::' || config.host === ip;
110114
const gn = '\x1b[38;5;114m'; // green
111115
const dm = '\x1b[2m'; // dim
112116

@@ -159,7 +163,8 @@ function createTermBeamServer(overrides = {}) {
159163
module.exports = { createTermBeamServer };
160164

161165
// Auto-start when run directly (CLI entry point)
162-
if (require.main === module || process.argv[1]?.endsWith('termbeam.js')) {
166+
const _entryBase = path.basename(process.argv[1] || '');
167+
if (require.main === module || _entryBase === 'termbeam' || _entryBase === 'termbeam.js') {
163168
const instance = createTermBeamServer();
164169

165170
process.on('SIGINT', () => {

0 commit comments

Comments
 (0)