new(core.gbapp): New API endpoint.
This commit is contained in:
parent
8568f62bdc
commit
367d9ead7e
1 changed files with 17 additions and 29 deletions
32
src/app.ts
32
src/app.ts
|
@ -252,32 +252,10 @@ export class GBServer {
|
|||
}
|
||||
|
||||
|
||||
server.post('*', async (req, res, next) => {
|
||||
|
||||
const host = req.headers.host;
|
||||
|
||||
// Roteamento com base no domínio.
|
||||
|
||||
if (host === process.env.API_HOST) {
|
||||
GBLog.info(`Redirecting to API...`);
|
||||
return httpProxy.web(req, res, { target: 'http://localhost:1111' }); // Express server
|
||||
}
|
||||
|
||||
await GBSSR.ssrFilter(req, res, next);
|
||||
|
||||
});
|
||||
|
||||
server.get('*', async (req, res, next) => {
|
||||
|
||||
const host = req.headers.host;
|
||||
|
||||
// Roteamento com base no domínio.
|
||||
|
||||
if (host === process.env.API_HOST) {
|
||||
GBLog.info(`Redirecting to API...`);
|
||||
return httpProxy.web(req, res, { target: 'http://localhost:1111' }); // Express server
|
||||
}
|
||||
|
||||
if (req.originalUrl.startsWith('/logs')) {
|
||||
if (process.env.ENABLE_WEBLOG === "true") {
|
||||
const admins = {
|
||||
|
@ -316,13 +294,23 @@ export class GBServer {
|
|||
if (process.env.CERTIFICATE_PFX) {
|
||||
|
||||
// Setups unsecure http redirect.
|
||||
const proxy = httpProxy.createProxyServer({});
|
||||
|
||||
const server1 = http.createServer((req, res) => {
|
||||
const host = req.headers.host.startsWith('www.') ?
|
||||
req.headers.host.substring(4) : req.headers.host;
|
||||
|
||||
if (host === process.env.API_HOST) {
|
||||
GBLog.info(`Redirecting to API...`);
|
||||
return proxy.web(req, res, { target: 'http://localhost:1111' }); // Express server
|
||||
}
|
||||
else {
|
||||
|
||||
res.writeHead(301, {
|
||||
Location: "https://" + host + req.url
|
||||
|
||||
}).end();
|
||||
}
|
||||
});
|
||||
server1.listen(80);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue