Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
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 org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import java.util.List;

Expand All @@ -30,6 +31,9 @@ public SecurityFilterChain appSecurity(HttpSecurity http) throws Exception {
// Turn off CSRF since we use JWT, not sessions
.csrf(csrf -> csrf.disable())

// Enable CORS with default configuration
.cors(Customizer.withDefaults())

// Allow /auth/** for public access, protect everything else
.authorizeHttpRequests(auth -> auth
.requestMatchers("/auth/**").permitAll()
Expand All @@ -52,7 +56,7 @@ public SecurityFilterChain appSecurity(HttpSecurity http) throws Exception {

// CORS configuration to allow requests from frontend
@Bean
public CorsFilter corsFilter() {
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); // allows cookies if needed
config.setAllowedOrigins(List.of("http://localhost:3000", "http://localhost:5173")); // frontend addresses
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has an extra space before "frontend addresses". This is a minor spelling/formatting issue.

Suggested change
config.setAllowedOrigins(List.of("http://localhost:3000", "http://localhost:5173")); // frontend addresses
config.setAllowedOrigins(List.of("http://localhost:3000", "http://localhost:5173")); // frontend addresses

Copilot uses AI. Check for mistakes.
Expand All @@ -62,6 +66,6 @@ public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);

return new CorsFilter(source);
return source;
}
}
2 changes: 1 addition & 1 deletion frontend/FishMaster/src/services/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// api.js
const DEV_MODE = true; // toggle to false in production
const DEV_MODE = false; // toggle to false in production

const API_BASE_URL = 'http://localhost:8080';

Expand Down