mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
cherry-pick features/react-routes
This commit is contained in:
parent
4e30ddeb1b
commit
50740211da
@ -387,7 +387,8 @@ Config.prototype.loadWebServerConfigFile = function() {
|
||||
"enabled": true,
|
||||
"host": defaultHost,
|
||||
"openBrowser": true,
|
||||
"port": 8000
|
||||
"port": 8000,
|
||||
"enableCatchAll": true
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');
|
||||
|
@ -23,6 +23,7 @@ class WebServer {
|
||||
|
||||
this.host = this.webServerConfig.host;
|
||||
this.port = parseInt(this.webServerConfig.port, 10);
|
||||
this.enableCatchAll = this.webServerConfig.enableCatchAll === true;
|
||||
|
||||
this.events.emit("status", __("Starting Server"));
|
||||
|
||||
|
@ -77,12 +77,13 @@ class Server {
|
||||
});
|
||||
});
|
||||
|
||||
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
|
||||
console.dir(apiCalls);
|
||||
for (let apiCall of apiCalls) {
|
||||
console.dir("adding " + apiCall.method + " " + apiCall.endpoint);
|
||||
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
|
||||
}
|
||||
if (self.plugins) {
|
||||
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
|
||||
for (let apiCall of apiCalls) {
|
||||
console.dir("adding " + apiCall.method + " " + apiCall.endpoint);
|
||||
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
|
||||
}
|
||||
}
|
||||
|
||||
this.app.ws('/', function(ws, _req) {
|
||||
self.events.on('outputDone', () => {
|
||||
@ -97,6 +98,13 @@ class Server {
|
||||
});
|
||||
});
|
||||
|
||||
if (this.enableCatchAll === true) {
|
||||
app.get('/*', function (req, res) {
|
||||
self.logger.trace('webserver> GET ' + req.path);
|
||||
res.sendFile(path.join(fs.dappPath(self.dist, 'index.html')));
|
||||
}
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function createPlaceholderPage(next) {
|
||||
if (!self.isFirstStart) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user