From deb255585e1f2ddb474e85ce1dc487e901d4724d Mon Sep 17 00:00:00 2001 From: izzat Date: Sat, 18 May 2024 12:35:59 +0800 Subject: [PATCH] update cross origin for web access --- .../sg/com/smartinventory/controllers/CustomerController.java | 3 ++- .../sg/com/smartinventory/controllers/ProductController.java | 3 ++- .../sg/com/smartinventory/controllers/ReviewController.java | 3 ++- src/main/resources/application.properties | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/sg/com/smartinventory/controllers/CustomerController.java b/src/main/java/sg/com/smartinventory/controllers/CustomerController.java index e781a5e..927db6f 100644 --- a/src/main/java/sg/com/smartinventory/controllers/CustomerController.java +++ b/src/main/java/sg/com/smartinventory/controllers/CustomerController.java @@ -28,7 +28,8 @@ @RestController @RequestMapping("/customers") -@CrossOrigin(origins = "http://localhost:5173") +// @CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(origins = "http://localhost:5173","${ALLOWED_ORIGIN}") public class CustomerController { private CustomerService customerService; diff --git a/src/main/java/sg/com/smartinventory/controllers/ProductController.java b/src/main/java/sg/com/smartinventory/controllers/ProductController.java index 372d97b..7c177e7 100644 --- a/src/main/java/sg/com/smartinventory/controllers/ProductController.java +++ b/src/main/java/sg/com/smartinventory/controllers/ProductController.java @@ -21,7 +21,8 @@ @RestController @RequestMapping("/products") -@CrossOrigin(origins = "http://localhost:5173") +// @CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(origins = "http://localhost:5173","${ALLOWED_ORIGIN}") public class ProductController { private ProductService productService; diff --git a/src/main/java/sg/com/smartinventory/controllers/ReviewController.java b/src/main/java/sg/com/smartinventory/controllers/ReviewController.java index 320e79e..5ccdf85 100644 --- a/src/main/java/sg/com/smartinventory/controllers/ReviewController.java +++ b/src/main/java/sg/com/smartinventory/controllers/ReviewController.java @@ -21,7 +21,8 @@ @RestController @RequestMapping("/reviews") -@CrossOrigin(origins = "http://localhost:5173") +// @CrossOrigin(origins = "http://localhost:5173") +@CrossOrigin(origins = "http://localhost:5173","${ALLOWED_ORIGIN}") public class ReviewController { private ReviewService reviewService; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c84cfd6..7189806 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,6 +4,7 @@ spring.application.name=smart-inventory # The default server port is 8080. server.port=${PORT:9090} +ALLOWED_ORIGIN=https://the-review-room-latest.onrender.com # Database Configuration. # PostgreSQL. spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/the_review_room}