Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오인제
/
Tunnel
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고병후
2021-12-05 03:09:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
39cb7f5137bfa6f8fba08e938c991c6f5cac21b9
39cb7f51
1 parent
fcab6ffa
Modify proxy
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
39 deletions
.gitignore
tunnel_BE/server/routes/login.js
tunnel_BE/server/routes/regiser.js → tunnel_BE/server/routes/register.js
tunnel_BE/server/server.js
turnel_FE/src/_actions/user_action.js
turnel_FE/src/_reducers/user_reducer.js
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
turnel_FE/src/setupProxy.js
.gitignore
View file @
39cb7f5
# 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
...
...
tunnel_BE/server/routes/login.js
View file @
39cb7f5
...
...
@@ -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"});
});
*/
...
...
tunnel_BE/server/routes/regiser.js
→
tunnel_BE/server/routes/regis
t
er.js
View file @
39cb7f5
...
...
@@ -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;
});
*/
...
...
tunnel_BE/server/server.js
View file @
39cb7f5
...
...
@@ -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/regis
t
er.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
);
//로그인 페이지
//에러처리 미들웨어
...
...
turnel_FE/src/_actions/user_action.js
View file @
39cb7f5
...
...
@@ -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
,
...
...
turnel_FE/src/_reducers/user_reducer.js
View file @
39cb7f5
...
...
@@ -8,7 +8,7 @@ export default function (state = {}, action) {
return
{
...
state
,
loginSuccess
:
action
.
payload
}
break
;
case
REGISTER_USER
:
return
{...
state
,
register
Success
:
action
.
payload
}
return
{...
state
,
register
:
action
.
payload
}
break
;
default
:
return
state
;
...
...
turnel_FE/src/component/views/RegisterPage/RegisterPage.js
View file @
39cb7f5
...
...
@@ -39,7 +39,7 @@ function RegisterPage(props) {
}
dispatch
(
registerUser
(
body
))
.
then
(
response
=>
{
if
(
response
.
payload
.
registerS
uccess
)
{
if
(
response
.
payload
.
s
uccess
)
{
props
.
history
.
push
(
'/login'
)
}
else
{
alert
(
'Failed to sign up'
)
...
...
turnel_FE/src/setupProxy.js
View file @
39cb7f5
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
,
})
);
...
...
Please
register
or
login
to post a comment