Skip to content

Commit 80f6d4f

Browse files
committed
replaced all static port names with variables to easily switch ports during development
1 parent c1f34e3 commit 80f6d4f

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

app/electron/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ app.on('web-contents-created', (event, contents) => {
213213
const validOrigins = [
214214
selfHost,
215215
'https://reactype-caret.herokuapp.com',
216-
'http://localhost:5000',
216+
`http://localhost:${process.env.PORT}`,
217217
'https://reactype.herokuapp.com',
218218
'https://github.com',
219219
'https://nextjs.org',
@@ -237,7 +237,7 @@ app.on('web-contents-created', (event, contents) => {
237237
const validOrigins = [
238238
selfHost,
239239
'https://reactype-caret.herokuapp.com',
240-
'http://localhost:5000',
240+
`http://localhost:${process.env.PORT}`,
241241
'https://reactype.herokuapp.com',
242242
'https://github.com',
243243
'https://nextjs.org',
@@ -280,7 +280,7 @@ app.on('web-contents-created', (event, contents) => {
280280
const validOrigins = [
281281
selfHost,
282282
'https://reactype-caret.herokuapp.com',
283-
'http://localhost:5000',
283+
`http://localhost:${process.env.PORT}`,
284284
'https://reactype.herokuapp.com',
285285
'https://nextjs.org',
286286
'https://developer.mozilla.org',
@@ -345,7 +345,7 @@ ipcMain.on('choose_app_dir', event => {
345345
// define serverURL for cookie and auth purposes based on environment
346346
let serverUrl = 'https://reactype-caret.herokuapp.com';
347347
if (isDev) {
348-
serverUrl = 'http://localhost:5000';
348+
serverUrl = `http://localhost:${process.env.PORT}`;
349349
}
350350

351351
// // for github oauth login in production, since cookies are not accessible through document.cookie on local filesystem, we need electron to grab the cookie that is set from oauth, this listens for an set cookie event from the renderer process then sends back the cookie
@@ -376,7 +376,7 @@ ipcMain.on('delete_cookie', event => {
376376
// opens new window for github oauth when button on sign in page is clicked
377377
ipcMain.on('github', event => {
378378
console.log('inside main.js in electron');
379-
const githubURL = 'http://localhost:5000/auth/github';
379+
const githubURL = `http://localhost:${process.env.PORT}/auth/github`;
380380
const options = {
381381
client_id: process.env.GITHUB_ID,
382382
client_secret: process.env.GITHUB_SECRET,

app/src/helperFunctions/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fetch = require('node-fetch');
22
const isDev = process.env.NODE_ENV === 'development';
33
let serverURL = 'https://reactype-caret.herokuapp.com';
44
if (isDev) {
5-
serverURL = 'http://localhost:5000';
5+
serverURL = `http://localhost:${process.env.PORT}`;
66
}
77
export const sessionIsCreated = (
88
username: string,

app/src/helperFunctions/projectGetSaveDel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const isDev = process.env.NODE_ENV === 'development';
22
let serverURL = 'https://reactype-caret.herokuapp.com';
33
if (isDev) {
4-
serverURL = 'http://localhost:5000';
4+
serverURL = `http://localhost:${process.env.PORT}`;
55
}
66
export const getProjects = (): Promise<any> => {
77
let userId = window.localStorage.getItem('ssid');

server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
Redeployment should also be done with only the server subtree and not the entire repo. See this <a href="https://medium.com/@shalandy/deploy-git-subdirectory-to-heroku-ea05e95fce1f">article</a> about deploying just a subdirectory.
1717

18-
If `npm` is your package manager, you just need to run the script `npm run dev` and it will start the server on `http://localhost:5000` for your development environment.
18+
If `npm` is your package manager, you just need to run the script `npm run dev` and it will start the server on `http://localhost:${process.env.PORT}` for your development environment.
1919

2020
Endpoint testing is currently integrated with Jest and Supertest as well and can be run by `npm run test` or `npm run test:watch` for watch mode.

server/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const projectController = require('./controllers/projectController');
1313

1414
const app = express();
1515

16-
const PORT = process.env.PORT || 5000;
16+
const PORT = process.env.PORT;
1717
const isDev = process.env.NODE_ENV === 'development';
1818
const isProd = process.env.NODE_ENV === 'production';
1919
const isTest = process.env.NODE_ENV === 'test';
@@ -43,7 +43,7 @@ passport.use(
4343
{
4444
clientID: process.env.GITHUB_ID,
4545
clientSecret: process.env.GITHUB_SECRET,
46-
callbackURL: 'http://localhost:5000/github/callback'
46+
callbackURL: `http://localhost:${process.env.PORT}/github/callback`
4747
},
4848
function(accessToken, refreshToken, profile, done) {
4949
console.log(profile);

webpack.development.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ module.exports = merge(base, {
1818
contentBase: path.resolve(__dirname, 'app/dist'), // Where we serve the local dev server's files from
1919
watchContentBase: true, // Watch the content base for changes
2020
watchOptions: {
21-
ignored: /node_modules/
21+
ignored: /node_modules/
2222
},
2323
proxy: {
2424
'/demoRender': {
25-
target: 'http://localhost:5000/'
25+
target: `http://localhost:${process.env.PORT}/`
2626
},
2727
'/user-styles': {
28-
target: 'http://localhost:5000/'
29-
},
30-
},
28+
target: `http://localhost:${process.env.PORT}/`
29+
}
30+
}
3131
},
3232
plugins: [
3333
// miniCssExtractPlugin is included here because it's used as a loader in wepack.config.js
@@ -39,5 +39,5 @@ module.exports = merge(base, {
3939
filename: 'index.html',
4040
nonce: nonce
4141
})
42-
],
42+
]
4343
});

0 commit comments

Comments
 (0)