From ee55dab367edbf2e4b0cfe2be67235453d1fb824 Mon Sep 17 00:00:00 2001 From: abidknashtech Date: Thu, 30 Nov 2023 20:58:52 +0530 Subject: [PATCH] fix CORS --- .../java/com/nashtech/car/cart/config/WebConfig.java | 9 +++++---- .../main/java/com.nashtech.order/config/WebConfig.java | 9 +++++---- projects-changes-deploy.txt | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cart-service/src/main/java/com/nashtech/car/cart/config/WebConfig.java b/cart-service/src/main/java/com/nashtech/car/cart/config/WebConfig.java index 11c02de2..f0c64145 100644 --- a/cart-service/src/main/java/com/nashtech/car/cart/config/WebConfig.java +++ b/cart-service/src/main/java/com/nashtech/car/cart/config/WebConfig.java @@ -1,19 +1,20 @@ package com.nashtech.car.cart.config; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@ComponentScan public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOrigins("http://34.23.248.115:4200/") // Allow requests from Angular app - .allowedMethods("GET", "POST", "PUT", "DELETE") + .allowedOrigins("*") + .allowedHeaders("origin", + "x-requested-with", "accept") + .allowedMethods("GET", "POST", + "PUT", "DELETE") .maxAge(3600); } } \ No newline at end of file diff --git a/order-service/src/main/java/com.nashtech.order/config/WebConfig.java b/order-service/src/main/java/com.nashtech.order/config/WebConfig.java index 5a2c6ada..b4b1c65a 100644 --- a/order-service/src/main/java/com.nashtech.order/config/WebConfig.java +++ b/order-service/src/main/java/com.nashtech.order/config/WebConfig.java @@ -1,19 +1,20 @@ package com.nashtech.order.config; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@ComponentScan public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOrigins("http://35.196.63.112:4200/") // Allow requests from Angular app - .allowedMethods("GET", "POST", "PUT", "DELETE") + .allowedOrigins("*") + .allowedHeaders("origin", + "x-requested-with", "accept") + .allowedMethods("GET", "POST", + "PUT", "DELETE") .maxAge(3600); } } \ No newline at end of file diff --git a/projects-changes-deploy.txt b/projects-changes-deploy.txt index 2312b174..3791ee64 100644 --- a/projects-changes-deploy.txt +++ b/projects-changes-deploy.txt @@ -1,3 +1,2 @@ -admin-service cart-service order-service \ No newline at end of file