Got rid of hardcoded urls
This commit is contained in:
parent
b57d20d055
commit
37e52d26b8
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"domain": "",
|
||||
"host": "localhost",
|
||||
"https": false,
|
||||
"domain": "localhost",
|
||||
"port": 7000,
|
||||
"openWebBrowser": true,
|
||||
"clientId": "XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
|
||||
|
|
17
index.js
17
index.js
|
@ -5,6 +5,16 @@ const host = config.host;
|
|||
const port = config.port;
|
||||
const openWebBrowser = config.openWebBrowser; // Set to false if running as a server
|
||||
|
||||
let full_url = "";
|
||||
const https = config.https;
|
||||
if(https) {
|
||||
full_url = "https://" + domain + ":" + port;
|
||||
} else {
|
||||
full_url = "http://" + domain + ":" + port;
|
||||
}
|
||||
|
||||
console.log("Server running on: " + full_url);
|
||||
|
||||
// Doesn't matter what Google account holds these keys.
|
||||
const clientId = config.clientId // Client ID from Google API page
|
||||
const clientSecret = config.clientSecret // Client Secret from Google API page
|
||||
|
@ -13,7 +23,7 @@ const clientSecret = config.clientSecret // Client Secret from Google API page
|
|||
const open = require('open');
|
||||
if (openWebBrowser) {
|
||||
(async () => {
|
||||
await open(`http://${host}:${port}/`);
|
||||
await open(full_url);
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -41,9 +51,8 @@ app.set('view engine', 'ejs');
|
|||
app.use(favicon(__dirname + '/public/assets/icons/favicon.ico'));
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
|
||||
res.render('pages/index', {
|
||||
domain: "map.winscloud.net",
|
||||
full_url: full_url,
|
||||
clientId: clientId
|
||||
});
|
||||
})
|
||||
|
@ -184,7 +193,7 @@ app.get('/auth', function (req, res) {
|
|||
const request = require('request');
|
||||
const options = {
|
||||
'method': 'POST',
|
||||
'url': `https://www.googleapis.com/oauth2/v4/token?client_id=${clientId}&client_secret=${clientSecret}&grant_type=authorization_code&code=${req.query["code"]}&redirect_uri=https://${domain}/auth/&scope=https://www.googleapis.com/auth/streetviewpublish`,
|
||||
'url': `https://www.googleapis.com/oauth2/v4/token?client_id=${clientId}&client_secret=${clientSecret}&grant_type=authorization_code&code=${req.query["code"]}&redirect_uri=${full_url}/auth/&scope=https://www.googleapis.com/auth/streetviewpublish`,
|
||||
'headers': {}
|
||||
};
|
||||
request(options, function (error, response) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div align="left">
|
||||
<h1>Get Started</h1>
|
||||
<p>Use the button below to authenticate your google account in order to use the service.</p>
|
||||
<a href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=<%= clientId %>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fstreetviewpublish&redirect_uri=https://<%= domain %>/auth/">
|
||||
<a href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=<%= clientId %>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fstreetviewpublish&redirect_uri=<%= full_url %>/auth/">
|
||||
<img src="https://developers.google.com/static/identity/images/btn_google_signin_dark_normal_web.png">
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue