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