Skip to content

Commit

Permalink
refactoring: cors 전체 허용
Browse files Browse the repository at this point in the history
  • Loading branch information
JangHwanPark committed Jun 21, 2024
1 parent df80eb0 commit ecdac3b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ const __dirname = path.dirname(__filename);
// 서버 설정
const app = express();
dotenv.config(); // 환경변수 읽어오기
const corsOptions = {
credentials: true,
origin: ['http://localhost:5000', 'http://34.197.44.20:5000'] // Whitelist the domains you want to allow
};
app.use(cors(corsOptions)); // 모든 프론트 서버 허용
app.use(cors()); // 모든 프론트 서버 허용
app.use(express.json()); // JSON 형식의 요청 본문을 파싱

// Index page
Expand Down
5 changes: 3 additions & 2 deletions src/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ <h1>특정 조건의 데이터 조회 API</h1>
<span id="book-count-2">책 아이디 1</span>
</div>
<div>
<p>GET</p><a href="http://34.197.44.20/coupang_products/product/1" target="_blank">/coupang_products/product/1</a>
<p>GET</p><a href="http://localhost:5000/coupang_products/product/1" target="_blank">/coupang_products
/product/1</a>
<span id="coupang-count-2">쿠팡 제품 아이디 1</span>
</div>
<div>
Expand Down Expand Up @@ -102,4 +103,4 @@ <h2>Guide</h2>
</div>
</div>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions src/view/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function fetchSpecificDatausers() {
async function fetchSpecificDatabooks() {
const input = document.getElementById('input-id-books').value;
try {
const response = await fetch(`http://34.197.44.20/books/info/${input}`);
const response = await fetch(`http://localhost:5000/books/info/${input}`);
const data = await response.json();
document.getElementById('result').textContent = JSON.stringify(data, null, 2);
} catch (error) {
Expand Down Expand Up @@ -88,4 +88,4 @@ document.addEventListener('DOMContentLoaded', function() {
});
});

window.onload = fetchData;
window.onload = fetchData;

0 comments on commit ecdac3b

Please sign in to comment.