Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for mobile app or web services to retrieve proxy URL to access MainUI #439

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if (config.system.subDomainCookies) {
if (app.get('env') === 'development') {
app.use(errorHandler());
}
if (system.getLoggerMorganOption()){
if (system.getLoggerMorganOption()) {
app.use(system.getLoggerMorganOption());
}
// App configuration for all environments
Expand Down Expand Up @@ -148,7 +148,7 @@ app.use(function (req, res, next) {
next(); // No host in header, just go ahead
}
// If host matches names for full /* proxying, go ahead and just proxy it.
if (host.indexOf('remote.') === 0 || host.indexOf('home.') === 0) {
if (host.indexOf('remote.') === 0 || host === system.getProxyHost()) {
//make sure this was not set by another server
if (req.url.indexOf('/remote') != 0) {
req.url = '/remote' + req.url;
Expand Down
10 changes: 10 additions & 0 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ exports.notificationssettingsget = function(req, res) {
}
res.send(config);
};

exports.proxyurlget = function(req, res) {
var config = {};


config.proxyurl = {
"url": system.getProxyURL()
};
res.send(config);
};
1 change: 1 addition & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ Routes.prototype.setupAppRoutes = function (app) {
// myOH API for mobile apps
app.all('/api/v1/notifications*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationsget);
app.all('/api/v1/settings/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationssettingsget);
app.all('/api/v1/proxyurl', this.ensureRestAuthenticated, this.preassembleBody, this.setOpenhab, api_routes.proxyurlget);

// Android app registration
app.all('/addAndroidRegistration*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, androidRegistrationService);
Expand Down