라우터

이소연's avatar
Aug 05, 2024
라우터
Contents
axios
notion image
 
app.js
import { Route, Routes } from "react-router-dom"; import Header from "./components/Header"; function App() { return ( <div> <Header /> <Routes> <Route path="/" element={<Home />} /> <Route path="/saveForm" element={<SaveForm />} /> <Route path="/post/:id" element={<Detail />} /> <Route path="/loginForm" element={<LoginForm />} /> <Route path="/joinForm" element={<JoinForm />} /> <Route path="/updateForm/:id" element={<UpdateForm />} /> </Routes> </div> ); } export default App;
notion image
notion image
was가 필요햄. js를 jsp로 읽기 위해?
 
client는 3가지만 다운받으면 됨.
그럼 다운 받을 수 있는 서버가 필요.
그걸 frontserver라고 함. 아파치만 설치되면 됨.
브라우저만 가능함.
 
파일요청하면 파일 그냥 주는 것. -아파치,nginx
was는 자바코드를 해석해서 주는 것.
notion image
notion image
최초에는 /post는 요청 x
최초에는 /만 됨.
single page~~라서?
관련 파일은 bundle안에 다 다운 받아야 한다고?
최초의 /요청이 안됨. / 요청하면 fs의 모든 js파일을 다 준다고?
 
 
client가 요청하는 것
notion image
cors
notion image
최초 요청한 도메인 주소가 브라우저 주소가 된다.
bs는 3000만 열어주면 된다고?
notion image
pri polite 요청-v
notion image
package com.cos.jwt.config.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; public class CorsFilter implements Filter{ public static final String TAG = "MyFilter1 : "; @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("CORS 필터 작동"); HttpServletResponse resp = (HttpServletResponse) response; resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Allow-Methods", "*"); resp.setHeader("Access-Control-Allow-Headers", "*"); // 해당 헤더가 없으면 아래 7가지의 header값만 응답할 수 있다. // Cache-Control //Content-Language //Content-Length //Content-Type //Expires //Last-Modified //Pragma resp.setHeader("Access-Control-Expose-Headers", "*"); chain.doFilter(request, response); } }
@RequiredArgsConstructor @Configuration public class FilterConfig { @Bean public FilterRegistrationBean<CorsFilter> corsFilter(){ System.out.println("CORS 필터 등록"); FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter()); bean.addUrlPatterns("/*"); bean.setOrder(0); // 낮은 번호부터 실행됨. return bean; } }
.env 파일 만들어서 환경변수 만드는 것.?
 
notion image
notion image
 
notion image
notion image
notion image
notion image
notion image
 
use selector
use dispatch
notion image
notion image
129.??99???_쌤거?
notion image
 

axios

notion image
notion image
notion image
notion image
notion image
notion image
 
key
youtube.
notion image
쌤 코드 참조
 
Share article

Coding's note