typedserver/ts/servertools/tools.sslredirect.ts
2024-02-20 17:30:46 +01:00

23 lines
521 B
TypeScript

import * as plugins from '../plugins.js';
import { Server } from './classes.server.js';
import { Handler } from './classes.handler.js';
export const redirectFrom80To443 = async () => {
const smartexpressInstance = new Server({
cors: true,
forceSsl: true,
port: 80,
});
smartexpressInstance.addRoute(
'*',
new Handler('ALL', async (req, res) => {
res.redirect('https://' + req.headers.host + req.url);
})
);
await smartexpressInstance.start();
return smartexpressInstance;
};