Skip to content

Commit

Permalink
Feat : Chat 230 CORS ํ—ˆ์šฉ (#27)
Browse files Browse the repository at this point in the history
* Fix : docker build args ๋ˆ„๋ฝ ์ˆ˜์ •

* Feat : CORS ์„ค์ •

FE์˜ ๋กœ์ปฌ ์ž‘์—…์„ ์œ„ํ•ด ๋ชจ๋“  origin์— ๋Œ€ํ•ด ํ—ˆ์šฉ ์„ค์ •

* Chore : cd ๋ธŒ๋žœ์น˜ ์„ค์ • ์ œ๊ฑฐ

* Feat : ์›น์†Œ์ผ“์—์„œ์˜ CORS๋„ ํ—ˆ์šฉ
  • Loading branch information
nonaninona authored Jan 27, 2024
1 parent d9dc10a commit c00f2c1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@ ARG JAR_PATH=/build/libs/*.jar
COPY ${JAR_PATH} /home/server.jar
ENTRYPOINT ["java","-jar","/home/server.jar"]
ARG OPEN_AI_KEY
ENV OPEN_AI_KEY=${OPEN_AI_KEY}
ENV OPEN_AI_KEY=${OPEN_AI_KEY}
ARG DEV_DB_HOST
ENV DEV_DB_HOST=${DEV_DB_HOST}
ARG DEV_DB_PASSWORD
ENV DEV_DB_PASSWORD=${DEV_DB_PASSWORD}
ARG DEV_DB_USER
ENV DEV_DB_USER=${DEV_DB_USER}
ARG PROD_DB_HOST
ENV PROD_DB_HOST=${PROD_DB_HOST}
ARG PROD_DB_PASSWORD
ENV PROD_DB_PASSWORD=${PROD_DB_PASSWORD}
ARG PROD_DB_USER
ENV PROD_DB_USER=${PROD_DB_USER}
ARG ACTIVE_PROFILE
ENV ACTIVE_PROFILE=${ACTIVE_PROFILE}
18 changes: 18 additions & 0 deletions src/main/java/com/kuit/chatdiary/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.kuit.chatdiary;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
public static final String ALLOWED_METHOD_NAMES = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,PATCH";

@Override
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods(ALLOWED_METHOD_NAMES.split(","))
.exposedHeaders(HttpHeaders.LOCATION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ChatWebSocketConfig implements WebSocketConfigurer {

@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(chatWebSocketHandler, "/chatwebsocket");
registry.addHandler(chatWebSocketHandler, "/chatwebsocket")
.setAllowedOrigins("*");
}
}

0 comments on commit c00f2c1

Please sign in to comment.