Skip to content

Commit

Permalink
Merge pull request #5 from Kusitms-28th-Hackathon-D/feat/qogustj
Browse files Browse the repository at this point in the history
Feat/qogustj
  • Loading branch information
qogustj authored Oct 7, 2023
2 parents ba02fa4 + 7d9fb48 commit 995cc5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/main/java/com/groupD/server/config/SpringSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;

import java.util.List;

@Configuration
@EnableWebSecurity
Expand All @@ -30,6 +34,19 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.httpBasic().disable()
.csrf().disable()
.cors(c -> {
CorsConfigurationSource source = request -> {
// Cors 허용 패턴
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(List.of("http://localhost:3000", "https://diamond-hackathon-kutisms.vercel.app/"));
config.setAllowedMethods(List.of("*"));
config.setAllowCredentials(true);

return config;
};
c.configurationSource(source);
}
)
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.groupD.server.controller;

import com.groupD.server.dto.SampleResponse;
import com.groupD.server.domain.dto.SampleResponse;
import com.groupD.server.service.SampleService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand All @@ -12,7 +12,7 @@
@RequiredArgsConstructor
@RequestMapping("/api/sample")
@RestController
//

public class SampleController {
private final SampleService sampleService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.groupD.server.dto;
package com.groupD.server.domain.dto;

import com.groupD.server.domain.Sample;
import lombok.AllArgsConstructor;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/groupD/server/service/SampleService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.groupD.server.service;

import com.groupD.server.domain.Sample;
import com.groupD.server.dto.SampleResponse;
import com.groupD.server.domain.dto.SampleResponse;
import com.groupD.server.repository.SampleRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down

0 comments on commit 995cc5c

Please sign in to comment.