Skip to content

Commit ef072b4

Browse files
committed
image redirect working
2 parents f87e2ef + 091b6b9 commit ef072b4

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
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 = isDev ? `http://localhost:${process.env.PORT}/auth/github` : 'app://rse/';
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/components/main/DemoRender.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ const DemoRender = (): JSX.Element => {
4242
document.querySelectorAll('a').forEach(element => {
4343
element.addEventListener('click', (event) => {
4444
event.preventDefault();
45-
window.top.postMessage(event.target.href, '*');
46-
})
45+
window.top.postMessage(event.currentTarget.href, '*');
46+
//document.body.style.backgroundColor = 'orange';
47+
}, true)
4748
});
4849
} catch (err) {
4950
const app = document.querySelector('#app');
@@ -57,6 +58,7 @@ const DemoRender = (): JSX.Element => {
5758

5859
//Switch between components when clicking on a link in the live render
5960
window.onmessage = (event) => {
61+
if(event.data === undefined) return;
6062
const component = event.data?.split('/').at(-1);
6163
const componentId = component && state.components?.find((el) => {
6264
return el.name.toLowerCase() === component.toLowerCase();
@@ -70,7 +72,6 @@ const DemoRender = (): JSX.Element => {
7072
const componentBuilder = (array: object, key: number = 0) => {
7173
const componentsToRender = [];
7274
for (const element of array) {
73-
console.log('array', array);
7475
if (element.name !== 'separator') {
7576
const elementType = element.name;
7677
const childId = element.childId;
@@ -112,7 +113,6 @@ const DemoRender = (): JSX.Element => {
112113
}, [])
113114

114115
useEffect(() => {
115-
console.log('code', code);
116116
iframe.current.contentWindow.postMessage(code, '*');
117117
}, [code])
118118

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)