정의왕

Remove error from master

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
tunnel_BE/server/node_modules
/.pnp
.pnp.js
......
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/OSSW.iml" filepath="$PROJECT_DIR$/.idea/OSSW.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -6,6 +6,10 @@ router.get('/',(req,res)=>{
res.send('회원가입 페이지');
});
router.post('/',(req,res)=>{
return res.status(201).json({success: true})
});
//라우트 매개변수사용
//뒤에 위치 요구
router.get("/:id",(req,res)=>{
......
......@@ -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,7 @@ 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(bodyParser().json);
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use(session({
resave: false,
......@@ -37,8 +37,8 @@ app.use(session({
//app.use('/',indexRouter);
//app.use('/login',loginRouter);
app.use('/',loginRouter); //로그인 페이지
app.use('/register',registerRouter); // 회원가입 페이지
//app.use('/',loginRouter); //로그인 페이지
app.use('/api/register',registerRouter); // 회원가입 페이지
//에러처리 미들웨어
......@@ -46,7 +46,6 @@ app.use('/register',registerRouter); // 회원가입 페이지
app.use((req,res,next)=>{
console.log("유저가 존재하지 않은 경로 접근");
res.status(404).send("NOT FOUND");
});
//포트를 연다.
......
......@@ -49,5 +49,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"proxy": "http://localhost:3001"
}
......
export const LOGIN_USER = "login_user";
export const REGISTER_USER = "register_user";
\ No newline at end of file
import Axios from 'axios';
import { LOGIN_USER, REGISTER_USER } from './types';
export function loginUser(dataToSubmit) {
const request = Axios.post('/api/users/login', dataToSubmit)
.then( response => response.data )
return {
type: LOGIN_USER,
payload: request
}
}
export function registerUser(dataToSubmit) {
const request = Axios.post('/api/users/register', dataToSubmit)
.then( response => response.data )
return {
type: REGISTER_USER,
payload: request
}
}
\ No newline at end of file
import { combineReducers } from 'redux';
import user from './user_reducer';
const rootReducer = combineReducers({
user
})
export default rootReducer;
import {
LOGIN_USER, REGISTER_USER
} from '../_actions/types';
export default function (state = {}, action) {
switch (action.type) {
case LOGIN_USER:
return { ...state, loginSuccess: action.payload }
break;
case REGISTER_USER:
return {...state, registerSuccess: action.payload}
break;
default:
return state;
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ function LoginPage(props) {
console.log("ID", Id);
console.log("Password", Password);
let body = {
email: Id,
id: Id,
password: Password
}
dispatch(loginUser(body))
......@@ -35,9 +35,7 @@ function LoginPage(props) {
alert('Error')
}
})
};
const goToRegister = () => {
navigate('/register');
}
......
......@@ -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,
})
);
......