@lethevimlet/sshift 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lethevimlet/sshift",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -225,14 +225,6 @@ async function initializeServer() {
225
225
  key: sslCredentials.key,
226
226
  cert: sslCredentials.cert
227
227
  }, app);
228
- server.on('request', (req, res) => {
229
- if (!req.socket.encrypted) {
230
- const host = req.headers.host ? req.headers.host.split(':')[0] : 'localhost';
231
- const port = getPort();
232
- res.writeHead(301, { Location: `https://${host}:${port}${req.url}` });
233
- res.end();
234
- }
235
- });
236
228
  actuallyHttps = true;
237
229
  console.log('[HTTPS] HTTPS server created with HTTP redirect enabled (dual-protocol)');
238
230
  } else {
@@ -282,6 +274,18 @@ async function initializeServer() {
282
274
  config,
283
275
  });
284
276
 
277
+ // HTTP to HTTPS redirect middleware (for dual-protocol httpolyglot server)
278
+ if (enableHttpRedirect) {
279
+ app.use((req, res, next) => {
280
+ if (!req.socket.encrypted) {
281
+ const host = req.headers.host ? req.headers.host.split(':')[0] : 'localhost';
282
+ const port = getPort();
283
+ return res.redirect(301, `https://${host}:${port}${req.url}`);
284
+ }
285
+ next();
286
+ });
287
+ }
288
+
285
289
  // Middleware
286
290
  app.use(express.json());
287
291