AWS

05. AWS 프론트 서버 배포하기

Heoky 2022. 2. 19. 05:45
$ npm install pm2

front/config/config.js 생성

export const backURL = process.env.NODE_ENV === 'production'
? 'http://13.124.161.143'
: 'http://localhost:3065';

saga/index.js

// sagas/index.js
import { all, fork } from 'redux-saga/effects';
import axios from 'axios';

import userSaga from './user';
import postSaga from './post';
import { backURL } from '../config/config';

axios.defaults.baseURL = backURL; // 여기에 config.js의 defaults URL 설정
axios.defaults.withCredentials = true;

export default function* rootSaga() {
  yield all([fork(userSaga), fork(postSaga)]);
}

이 외에 이미지에 설정된 url도 변경해준다.

package.json

"scripts": {
    "dev": "next -p 3060",
    "build": "cross-env ANALYZE=true NODE_ENV=production next build",
    "start": "cross-env NODE_ENV=production next start -p 80" // 80으로 port 변경
  },

git commit push 해준다.

 


Ubunto

$ sudo git pull
$ npm install
// 프론트 서버 실행
$ npx pm2 start npm -- start

'AWS' 카테고리의 다른 글

[AWS] nginx + https 적용하기  (0) 2022.02.21
04. AWS pm2 사용하기  (0) 2022.02.18
03. AWS Ubuntu에 MySQL 설치하기  (0) 2022.02.18
02. Ubuntu에 Node 설치하기  (0) 2022.02.18
01. AWS EC2 생성하기  (0) 2022.02.17