vs 코드(vite.config.js에 아래와 같이 작성)
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api': '<http://localhost:8081>',
},
},
})
STS(HealthController 추가)
package com.workflow;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class HealthController {
@GetMapping("/health")
public String health() {
return "OK";
}
}
둘다 실행하고 바이트 기본 포트번호로 접속
// 경로 이동
cd my-react-app
// vite 실행
npm run dev
<http://localhost:5173>
포트번호 바꾸고 싶다면 서버 부분에 포트 번호 지정