#14 simple blog : cors

This commit is contained in:
haerong22
2022-07-31 03:30:11 +09:00
parent 5a76744191
commit 57a3b7bf6f
3 changed files with 28 additions and 2 deletions

View File

@@ -7,8 +7,10 @@ const content = ref("");
const write = () => { const write = () => {
console.log("hi") axios.post("/api/posts", {
axios.get("http://localhost:8080"); title: title.value,
content: content.value,
});
} }
</script> </script>

View File

@@ -12,4 +12,13 @@ export default defineConfig({
"@": fileURLToPath(new URL("./src", import.meta.url)), "@": fileURLToPath(new URL("./src", import.meta.url)),
}, },
}, },
server: {
proxy: {
"/api": {
target: "http://localhost:8080",
rewrite: (path) => path.replace(/^\/api/, ""),
},
}
}
}); });

View File

@@ -0,0 +1,15 @@
//package com.example.simpleblog.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//@Configuration
//public class WebConfig implements WebMvcConfigurer {
//
// @Override
// public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**")
// .allowedOrigins("http://localhost:5173");
// }
//}