Skip to content

Commit

Permalink
feat(apitest.jsx): use backend address depending on environment
Browse files Browse the repository at this point in the history
  • Loading branch information
junglesub committed Jul 26, 2024
1 parent 5c7a372 commit cd2bc62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const serverRootUrl =
!process.env.NODE_ENV || process.env.NODE_ENV === "development"
? "http://localhost:8080"
: "https://woomool-be.handong.app";
4 changes: 3 additions & 1 deletion src/pages/ApiTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container } from "../styles/Container";
import { useRecoilValue } from "recoil";
import { authJwtAtom } from "../recoil/auth/atoms";
import styled from "styled-components";
import { serverRootUrl } from "../constants";

const presets = [
{
Expand Down Expand Up @@ -82,7 +83,7 @@ function ApiTest() {
};

const sendApiRequest = () => {
fetch("http://localhost:8080" + targetEndPoint, {
fetch(serverRootUrl + targetEndPoint, {
method: requestType,
headers: {
Authorization: `Bearer ${jwtValue}`,
Expand All @@ -98,6 +99,7 @@ function ApiTest() {
<Container>
<ApiTestC>
<h1>Api TEST</h1>
<div>Server Root Url: {serverRootUrl}</div>
<h3>JWT Token</h3>
<input value={jwtValue} readOnly />
<h3>Target Endpoint</h3>
Expand Down

0 comments on commit cd2bc62

Please sign in to comment.