1. AWS ELB 설정

2. 리액트 접근 시 문제 확인

Refused to execute script from static/js/bundle.js because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

3. 참고

4. 해결 - 리액트 환경 변수 설정

PUBLIC_URL=/something

5. 해결 - 정적 HTML 페이지 루트 경로 설정

<!doctype html>
<html lang="en">
    <head>
        ...
        <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
        ...
    </head>
    <body>
        <noscript>You.</noscript>
        <div id="root"></div>
    </body>
</html>

6. 라우팅 설정(App.tsx)

import { Route, Routes, Navigate } from "react-router";
import React from "react";
import { BrowserRouter } from "react-router-dom";

export default function App() {
    return (
        <BrowserRouter>
            <Routes>
            
                // 루트 -> 다른 경로 리다이렉트 방법 1
                {/* <Route path="/something" element={<Navigate to="/something/dev" replace />} /> */}
                
								// 공통 패스 설정
                <Route path="/something">
                
                    // 루트 -> 다른 경로 리다이렉트 방법 2
                    <Route path=""    element={<Navigate to="/something/dev" replace />} />
                    
                    // 공통 Route 하위의 Route에서 path 시작에는 /를 붙이지 않는다.
                    <Route path="dev" element={<UnityMain />} />
                    <Route path="web" element={<UnityMain />} />
                </Route>

            </Routes>
        </BrowserRouter>
    );
}

7. 추가: 빌드 후 Nginx로 정적 파일 라우팅하는 경우