고병후

Modify proxy

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
tunnel_BE/server/node_modules
......
......@@ -3,17 +3,18 @@ const bodyParser = require("body-parser");
const router = express.Router();
router.get('/',(req,res)=>{
res.send('로그인 페이지');
//res.send('로그인 페이지');
});
//라우트 매개변수사용
//후방 위치 요구
/*
router.get("/:id",(req,res)=>{
console.log(req.body);
res.json({id:"oss_hi"});
//res.json({id:"oss_hi"});
});
*/
......
......@@ -2,16 +2,23 @@ const express = require("express");
const bodyParser = require("body-parser");
const router = express.Router();
router.post('/',(req,res)=>{
console.log(req.body);
});
router.get('/',(req,res)=>{
res.send('회원가입 페이지');
//res.json({id: "hi"});
//console.log(res.body);
});
//라우트 매개변수사용
//뒤에 위치 요구
/*
router.get("/:id",(req,res)=>{
console.log(req.params, req.query);
req.body;
//req.body;
});
*/
......
......@@ -9,7 +9,7 @@ const bodyParser = require("body-parser");
dotenv.config();
const indexRouter = require('./routes/index.js');
const loginRouter = require('./routes/login.js');
const registerRouter = require('./routes/regiser.js');
const registerRouter = require('./routes/register.js');
const app = express();
app.set('port', process.env.PORT || 3001);
......@@ -19,7 +19,6 @@ const port = app.get('port');
app.use(morgan('dev'));
app.use(express.json()); //json형식으로 데이터 전달
app.use(express.urlencoded({extende: false})); // url형식으로 형식으로 데이터 전달
app.use(bodyParser().json);
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use(session({
resave: false,
......@@ -37,8 +36,9 @@ app.use(session({
//app.use('/',indexRouter);
//app.use('/login',loginRouter);
app.use('/',loginRouter); //로그인 페이지
app.use('/register',registerRouter); // 회원가입 페이지
app.use('/api/register',registerRouter); // 회원가입 페이지
app.use('/api/login',loginRouter); //로그인 페이지
//에러처리 미들웨어
......
......@@ -3,7 +3,7 @@ import { LOGIN_USER, REGISTER_USER } from './types';
export function loginUser(dataToSubmit) {
const request = Axios.post('/api/users/login', dataToSubmit)
const request = Axios.post('/api/login', dataToSubmit)
.then( response => response.data )
return {
type: LOGIN_USER,
......@@ -13,7 +13,7 @@ export function loginUser(dataToSubmit) {
export function registerUser(dataToSubmit) {
const request = Axios.post('/api/users/register', dataToSubmit)
const request = Axios.post('/api/register', dataToSubmit)
.then( response => response.data )
return {
type: REGISTER_USER,
......
......@@ -8,7 +8,7 @@ export default function (state = {}, action) {
return { ...state, loginSuccess: action.payload }
break;
case REGISTER_USER:
return {...state, registerSuccess: action.payload}
return {...state, register: action.payload}
break;
default:
return state;
......
......@@ -39,7 +39,7 @@ function RegisterPage(props) {
}
dispatch(registerUser(body))
.then(response => {
if (response.payload.registerSuccess) {
if (response.payload.success) {
props.history.push('/login')
} else {
alert('Failed to sign up')
......
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:3000',
createProxyMiddleware('/api',{
target: 'http://localhost:3001',
changeOrigin: true,
})
);
......