Commit 81cf8c01 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

root url

parent 49cf22e1
...@@ -11,6 +11,13 @@ const reservesRouter = require('./routes/reserves'); ...@@ -11,6 +11,13 @@ const reservesRouter = require('./routes/reserves');
const noticeRouter = require('./routes/notices'); const noticeRouter = require('./routes/notices');
const writesRouter = require('./routes/writes'); const writesRouter = require('./routes/writes');
// 배포용?
const isProduction = process.env.NODE_ENV === 'production'
let root_url = '/'
if (isProduction) {
root_url = '/app/rental'
}
const CURRENT_WORKING_DIR = process.cwd() const CURRENT_WORKING_DIR = process.cwd()
const app = express() const app = express()
...@@ -22,12 +29,12 @@ app.use(cors()) ...@@ -22,12 +29,12 @@ app.use(cors())
console.log('path=', path.join(CURRENT_WORKING_DIR, 'client', 'build')) console.log('path=', path.join(CURRENT_WORKING_DIR, 'client', 'build'))
app.use('/', express.static(path.join(CURRENT_WORKING_DIR, 'client', 'build'))) app.use('/', express.static(path.join(CURRENT_WORKING_DIR, 'client', 'build')))
app.use('/api/', indexRouter); app.use(path.join(root_url, '/api/'), indexRouter);
app.use('/api/users', usersRouter, reservesRouter); app.use(path.join(root_url, '/api/users'), usersRouter, reservesRouter);
app.use('/api/login', loginRouter); app.use(path.join(root_url, '/api/login'), loginRouter);
app.use('/api/reserves', reservesRouter); app.use(path.join(root_url, '/api/reserves'), reservesRouter);
app.use('/api/notices', noticeRouter); app.use(path.join(root_url, '/api/notices'), noticeRouter);
app.use('/api/writes', writesRouter); app.use(path.join(root_url, '/api/writes'), writesRouter);
app.use((err, req, res, next) => { app.use((err, req, res, next) => {
if (err.name === 'UnauthorizedError') { if (err.name === 'UnauthorizedError') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment