Skip to content

Commit be010fb

Browse files
authored
Merge pull request #25 from oslabs-beta/calvin
fixed being able to connect to heroku server on prod version
2 parents 57ad211 + 091b6b9 commit be010fb

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
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:${process.env.PORT}`,
216+
`http://localhost:${process.env.DEV_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:${process.env.PORT}`,
240+
`http://localhost:${process.env.DEV_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:${process.env.PORT}`,
283+
`http://localhost:${process.env.DEV_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:${process.env.PORT}`;
348+
serverUrl = `http://localhost:${process.env.DEV_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:${process.env.PORT}/auth/github`;
379+
const githubURL = `http://localhost:${process.env.DEV_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:${process.env.PORT}`;
5+
serverURL = `http://localhost:${process.env.DEV_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:${process.env.PORT}`;
4+
serverURL = `http://localhost:${process.env.DEV_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:${process.env.PORT}` 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.DEV_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: 3 additions & 3 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;
16+
const PORT = process.env.PORT || process.env.DEV_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';
@@ -29,7 +29,7 @@ const stylesRouter = require('./routers/stylesRouter');
2929
// options: origin: allows from localhost when in dev or the app://rse when using prod, credentials: allows credentials header from origin (needed to send cookies)
3030
app.use(
3131
cors({
32-
origin: ['http://localhost:8080', 'app://rse'],
32+
origin: [`http://localhost:8080`, 'app://rse'],
3333
credentials: true
3434
})
3535
);
@@ -43,7 +43,7 @@ passport.use(
4343
{
4444
clientID: process.env.GITHUB_ID,
4545
clientSecret: process.env.GITHUB_SECRET,
46-
callbackURL: `http://localhost:${process.env.PORT}/github/callback`
46+
callbackURL: `http://localhost:${process.env.DEV_PORT}/github/callback`
4747
},
4848
function(accessToken, refreshToken, profile, done) {
4949
console.log(profile);

webpack.development.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ module.exports = merge(base, {
2222
},
2323
proxy: {
2424
'/demoRender': {
25-
target: `http://localhost:${process.env.PORT}/`
25+
target: `http://localhost:${process.env.DEV_PORT}/`
2626
},
2727
'/user-styles': {
28-
target: `http://localhost:${process.env.PORT}/`
28+
target: `http://localhost:${process.env.DEV_PORT}/`
2929
}
3030
}
3131
},

0 commit comments

Comments
 (0)