feat: another attempt to fix backend cors

This commit is contained in:
2024-10-05 14:58:48 -03:00
parent 6e820c9104
commit e501e2b4a4
4 changed files with 27 additions and 5 deletions
+2
View File
@@ -45,6 +45,7 @@ function handleError(httpStatusCode: number) {
const api = {
getJSON: async (url: string) => {
console.log(`getJSON=${url}`);
const response = await fetch(url, {
method: 'GET',
mode: 'cors',
@@ -63,6 +64,7 @@ const api = {
},
postJSON: async (url: string, payload: object) => {
console.log(`postJSON=${url}`);
const response = await fetch(url, {
method: 'POST',
mode: 'cors',
@@ -18,7 +18,7 @@ public class CorsConfig implements WebMvcConfigurer {
/**
* Add CORS mappings configuration.
*
*
* @param registry CorsRegistry instance.
*/
public void addCorsMappings(@NonNull CorsRegistry registry) {
@@ -29,7 +29,14 @@ public class CorsConfig implements WebMvcConfigurer {
.addMapping("/**")
.allowedOrigins(allowedOrigins)
.allowCredentials(true)
.allowedHeaders("X-XSRF-TOKEN", "Content-Type", "Accept", "Authorization", "X-Frame-Options", "X-XSS-Protection", "Content-Security-Policy")
.allowedHeaders(
"X-XSRF-TOKEN",
"Content-Type",
"Accept",
"Authorization",
"X-Frame-Options",
"X-XSS-Protection",
"Content-Security-Policy")
.allowedMethods("GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH");
}
}
@@ -52,9 +52,9 @@ public class SecurityConfig {
request
.requestMatchers(HttpMethod.OPTIONS, "/**")
.permitAll()
.requestMatchers("/auth/**")
.requestMatchers("/server/auth/**", "/auth/**")
.permitAll()
.requestMatchers("/rest/**")
.requestMatchers("/server/rest/**", "/rest/**")
.authenticated()
.anyRequest()
.permitAll())
+14 -1
View File
@@ -87,4 +87,17 @@ docker compose --file docker-compose.prod.yml up -d db
```
- Get container IP
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db
# Manual Client build & deploy
```sh
export VERSION=
export IP=
npm ci --ignore-scripts --no-update-notifier --omit=dev
export VITE_BACKEND_SERVER=/server
npm run build
zip -r client_$VERSION.zip dist/
scp client_86.zip root@$IP:/root/
```