Giter Club home page Giter Club logo

create-react-flask's Introduction

Maintainability

create-react-app + flask

If you really want to create a client react app with session-based authentication.

It does seem counter-intuative to use a stateful server with a stateless Single Page App, but there may be situations (eg. required to integrate with an existing session-based Api) where you can't use tokens.

Notes:

  • for cookies to work, the Api must be hosted on the same domain as the site. On localhost, Api calls are be proxied to localhost:5000.
  • with the source of truth being the server, when the app first loads it tries to ping an endpoint to determine if the cookie is still valid, and set the correct lsLoggedIn value in state. The front end does not track cookie expiry, etc.
  • if isLoggedIn: true and the cookie does expire, the server will return a 401 and the app redux state will change to isLoggedIn: false

React structure inspired by this container pattern.

Auth managed via flask-login.

Redux actions/reducers based on login-flow.

Start the frontend:

cd client
nvm use
npm install
npm start

Start the backend:

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python run.py

Run prettier:

npm run prettier

create-react-flask's People

Contributors

matt-sm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.