|
|
@ -35,11 +35,12 @@ const { |
|
|
} = require('../config'); |
|
|
} = require('../config'); |
|
|
|
|
|
|
|
|
module.exports = class Server { |
|
|
module.exports = class Server { |
|
|
|
|
|
|
|
|
constructor() { |
|
|
constructor() { |
|
|
const app = createApp(); |
|
|
const app = createApp(); |
|
|
this.app = app; |
|
|
this.app = app; |
|
|
|
|
|
|
|
|
// Middleware to add CORS headers
|
|
|
// Middleware to add CORS headers
|
|
|
app.use('*', defineEventHandler((event) => { |
|
|
app.use('*', defineEventHandler((event) => { |
|
|
setHeader(event, 'Access-Control-Allow-Origin', '*'); // Allows all origins
|
|
|
setHeader(event, 'Access-Control-Allow-Origin', '*'); // Allows all origins
|
|
|
setHeader(event, 'Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); // Allowed methods
|
|
|
setHeader(event, 'Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); // Allowed methods
|
|
|
@ -254,4 +255,5 @@ module.exports = class Server { |
|
|
createServer(toNodeListener(app)).listen(PORT, WEBUI_HOST); |
|
|
createServer(toNodeListener(app)).listen(PORT, WEBUI_HOST); |
|
|
debug(`Listening on http://${WEBUI_HOST}:${PORT}`); |
|
|
debug(`Listening on http://${WEBUI_HOST}:${PORT}`); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|