Skip to content

Instantly share code, notes, and snippets.

View Hurly77's full-sized avatar
🏠
Working from home

Cameron J. Leverett Hurly77

🏠
Working from home
View GitHub Profile
gem install bcrypt
gem install rack-cors
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root')
);
App.js
index.js
src
-Redux_
|
-actions
-<empty>
|
-reducers
|
import { createStore, combineReducers, compose, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
const rootReducer = combineReducers({
\*leave empty for now*\
})
const middleware = [thunk, reduxLogger]
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const authReducer = (
state = {
loggedIn : false,
currentUser : {},
},
action,
) => {
switch (action.type) {
case 'AUTH_SUCCESS':
return {
const authReducer = (
state = {
loggedIn: false,
currentUser: {},
},
action,
) => {
switch (action.type) {
case 'AUTH_SUCCESS':
return {
export const signup = (user) => {
return (dispatch) => {
fetch(`${apiUrl}/users`, {
// will set this up in the future
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ user: user }),
})
.then((res) => res.json())
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { Provider } from 'react-redux';
import store from './Redux'
ReactDOM.render(
<Provider store={store}>
<App />
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'http://localhost:3000'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head],
credentials: true // absoultly remember to set this in to true, and in your ajax to set credentials: 'include'
end
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'http://localhost:3000'
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head],
credentials: true
# absoultly remember to set this in to true, and in your ajax to set credentials: 'include'
end