Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fe dockerfile #66

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions urmine-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ WORKDIR /usr/src/app

COPY . .

RUN npm install

RUN npm run build

WORKDIR /usr/src/app/build
Expand Down
21 changes: 21 additions & 0 deletions urmine-frontend/src/Routes/Pokedex.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { getToken } from "../api/user";
import PokeSeal from "../components/PokeSeal";
import Search from "../components/Search";

Expand Down Expand Up @@ -278,7 +281,25 @@ const PokeContainer = styled.main`
gap: 60px 0px;
`;

let code = new URL(window.location.href).searchParams.get("code");

function Pokedex() {
const navigate = useNavigate();

async function kakaoLogin(code: string) {
const data = JSON.parse(await getToken(code));
if (data.status !== 500) {
localStorage.setItem("accessToken", data.accessToken);
navigate("/pokedex");
}
}

useEffect(() => {
if (code !== null) {
kakaoLogin(code);
}
}, []);

return (
<>
<Search></Search>
Expand Down
13 changes: 9 additions & 4 deletions urmine-frontend/src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const BASE_URL = "http://15.164.97.14:8080/api/user";
const BASE_URL = "http://urmine.site:8080/api/user";

export async function getKakaoLoginPage() {
const url = await (
await fetch("http://15.164.97.14:8080/api/user/kakao/page")
).text();
const url = await (await fetch(`${BASE_URL}/kakao/page`)).text();
return url;
}

export async function getToken(code: string) {
const token = await (
await fetch(`${BASE_URL}/kakao/login?code=${code}`)
).text();
return token;
}