Skip to content

Commit

Permalink
Upgrade to CRA 2.0 (fixed proxy!)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanchristie committed Mar 22, 2019
1 parent 64ca98d commit e396337
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 39 deletions.
24 changes: 12 additions & 12 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": {
"/auth/*": {
"target": "http://localhost:5000"
},
"/api/*": {
"target": "http://localhost:5000"
}
},
"proxy": "http://localhost:5000",
"dependencies": {
"axios": "^0.18.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"http-proxy-middleware": "^0.19.1",
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-share": "^2.3.1",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"react-scripts": "1.1.4"
"react-scripts": "2.1.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
12 changes: 6 additions & 6 deletions client/src/components/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ class Card extends Component {
</div>
<div className="card-action">
{ isSaved ?
<a onClick={this.removeQuote} href="">
<p onClick={this.removeQuote}>
<i className="fa fa-times center"></i>
Remove Quote
</a>
</p>
:
<a onClick={this.saveQuote} href="">
<p onClick={this.saveQuote}>
<i className="fa fa-plus center"></i>
Save Quote
</a>
</p>
}

<a href=""><i className="fa fa-facebook right"></i></a>
<a href=""><i className="fa fa-twitter right"></i></a>
<p><i className="fa fa-facebook right"></i></p>
<p><i className="fa fa-twitter right"></i></p>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Header extends Component {
<Link to="/" className="brand-logo">Inspiri</Link>
{ Object.keys(user).length ?
<Fragment>
<a href="" data-target="slide-out" className="sidenav-trigger">
<button data-target="slide-out" className="sidenav-trigger">
<i className="fa fa-bars fa-2x"></i>
</a>
</button>
<ul id="nav-mobile" className="right hide-on-med-and-down">
<li><Link to="/explore">Explore</Link></li>
<li><Link to="/dashboard">Profile</Link></li>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const LandingPage = () => {
<i className="fa fa-google" style={{marginRight: "10px"}}></i>
Login With Google
</a>
<a href="/test">Test</a>
</section>
)
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const proxy = require('http-proxy-middleware')

module.exports = (app) => {
app.use(proxy('/auth/**', { target: 'http://localhost:5000'}))
app.use(proxy('/api/**', { target: 'http://localhost:5000'}))
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express'),
mongoose = require('mongoose'),
bodyParser = require('body-parser'),
cors = require('cors'),
//cors = require('cors'),
cookieSession = require('cookie-session'),
passport = require('passport'),
keys = require('./config/keys'),
Expand All @@ -19,7 +19,7 @@ const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
//app.use(cors({ credentials: true}));

// Session middleware

Expand Down
9 changes: 4 additions & 5 deletions routes/facebookRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ module.exports = (app) => {

app.get('/auth/facebook', passport.authenticate('facebook'));

app.get('/auth/facebook/callback', passport.authenticate('facebook', {
successRedirect: '/dashboard',
failureRedirect: '/'
}));

app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/' }),
(req, res) => res.redirect('/dashboard')
);

}
2 changes: 1 addition & 1 deletion routes/genRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = (app) => {

app.get('/api/user', (req, res) => {
res.send(req.user)
});
})

app.get('/api/logout', (req, res) => {
req.logout();
Expand Down
8 changes: 4 additions & 4 deletions routes/googleRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module.exports = (app) => {
scope: ['email', 'profile']
}));

app.get('/auth/google/callback', passport.authenticate('google', {
successRedirect: '/dashboard',
failureRedirect: '/'
}));
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/'}),
(req, res) => res.redirect('/dashboard')
);

}
9 changes: 4 additions & 5 deletions routes/twitterRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ module.exports = (app) => {

app.get('/auth/twitter', passport.authenticate('twitter'));

app.get('/auth/twitter/callback', passport.authenticate('twitter', {
successRedirect: '/dashboard',
failureRedirect: '/'
}));

app.get('/auth/twitter/callback',
passport.authenticate('twitter', { failureRedirect: '/' }),
(req, res) => res.redirect('/dashboard')
);

}
3 changes: 1 addition & 2 deletions services/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const GoogleStrategy = require('passport-google-oauth20').Strategy,
// Serialize & Deserialize ID

passport.serializeUser((user, done) => {
console.log(user)
done(null, user._id)
});

Expand Down Expand Up @@ -60,7 +61,6 @@ passport.use(
},
async (accessToken, refreshToken, profile, done) => {
const existingUser = await User.findOne({ id: profile.id});

if (existingUser) {
return done(null, existingUser)
}
Expand All @@ -87,7 +87,6 @@ passport.use(
passReqToCallback: true
},
async (accessToken, refreshToken, profile, done) => {
console.log(profile)
const existingUser = await User.findOne({ id: profile.id });

if (existingUser) {
Expand Down

0 comments on commit e396337

Please sign in to comment.