This is a simple web application that supports "Login with Twitter" via Twitter OAuth. Sessions are Stored in MongoDB.
The API is deployed on Heroku and the Frontend on Netlify.
- Create a developer account on Twitter (must have elevated access)
- Add
http://localhost:4000/auth/redirect
to theRedirect URL
section in Twitter - Rename .env.copy file to .env and adjust your credentials
- Start frontend (http://localhost:3000)
cd client/
npm install
npm run dev
-
Start backend (http://localhost:4000) and DB
Make sure you got the local/live DB set up an adjusted the credentials and paths ind the
.env
andserver/config/globals.js
file. You may need to update the cluster name in the prodMongoURL connection link.
cd server/
npm install
# Use local MongoDB
npm run db
npm run dev
# or use production MongoDB
npm run start
mongosh # connect to deployed MongoDB
> show dbs # show all available db's
> use userDB # (your name may be different)
> db.sessions.find() # list all sessions
> db.users.find() # list all users
- Add
https://your-heroku-app.herokuapp.com/auth/redirect
to theRedirect URL
section in Twitter - Adjust the Heroku and Netlify links in
server/config/globals
to your apps
Settings | Value |
---|---|
Base directory | client/ |
Build command | npm run build |
Publish directory | client/build |
- set the following environment variables:
- COOKIE_KEY
- DB_PASSWORD
- DB_USER
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
- PROJECT_PATH = server
- add the buildpacks
heroku/nodejs
andhttps://github.com/timanovsky/subdir-heroku-buildpack
- MongoDB
- mongoose
- Express.js
- React
- Node.js
- Passport.js