Merge pull request #4 from WinsDominoes/master

Got rid of hardcoded urls
This commit is contained in:
moom0o 2023-04-08 00:01:26 -04:00 committed by GitHub
commit af432c2827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"domain": "", "https": false,
"host": "localhost", "domain": "localhost",
"port": 7000, "port": 7000,
"openWebBrowser": true, "openWebBrowser": true,
"clientId": "XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com", "clientId": "XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",

View File

@ -5,6 +5,16 @@ const host = config.host;
const port = config.port; const port = config.port;
const openWebBrowser = config.openWebBrowser; // Set to false if running as a server 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. // Doesn't matter what Google account holds these keys.
const clientId = config.clientId // Client ID from Google API page const clientId = config.clientId // Client ID from Google API page
const clientSecret = config.clientSecret // Client Secret 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'); const open = require('open');
if (openWebBrowser) { if (openWebBrowser) {
(async () => { (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.use(favicon(__dirname + '/public/assets/icons/favicon.ico'));
app.get('/', function (req, res) { app.get('/', function (req, res) {
res.render('pages/index', { res.render('pages/index', {
domain: "map.winscloud.net", full_url: full_url,
clientId: clientId clientId: clientId
}); });
}) })
@ -184,7 +193,7 @@ app.get('/auth', function (req, res) {
const request = require('request'); const request = require('request');
const options = { const options = {
'method': 'POST', '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': {} 'headers': {}
}; };
request(options, function (error, response) { request(options, function (error, response) {

View File

@ -4,7 +4,7 @@
<div align="left"> <div align="left">
<h1>Get Started</h1> <h1>Get Started</h1>
<p>Use the button below to authenticate your google account in order to use the service.</p> <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"> <img src="https://developers.google.com/static/identity/images/btn_google_signin_dark_normal_web.png">
</a> </a>
</div> </div>