안형욱

config: dontenv setting 및 필요한 환경 변수 추가

......@@ -22,4 +22,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode
\ No newline at end of file
.vscode
.env
\ No newline at end of file
......
REACT_APP_API_ENDPOINT={API_ENDPOINT}
REACT_APP_SEARCH_KEY={SEARCH_KEY}
REACT_APP_ENGINE_NAME={ENGINE_NAME}
\ No newline at end of file
import React from 'react';
import { createGlobalStyle } from 'styled-components';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import dotenv from 'dotenv';
import HomePage from './pages/HomePage';
import LoginPage from './pages/LoginPage';
import SearchPage from './pages/SearchPage';
dotenv.config();
const GlobalStyle = createGlobalStyle`
html,
body,
......
import axios from 'axios';
const esInstance = axios.create({
baseURL: process.env.API_ENDPOINT,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.SEARCH_KEY}`,
},
});
export const search = async searchWord => {
const res = await esInstance.post(
`/api/as/v1/engines/${process.env.APP_SEARCH_ENGINE_NAME}/search`,
{
query: searchWord,
}
);
console.log(res);
return res;
};