diff --git a/pom.xml b/pom.xml index 2b3ff05d3b5eaf202ba52c5cfcdd3a1757658f8a..2d824c622ec8fcf1fa8fd3d039617514f3a88e35 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,12 @@ <artifactId>spring-boot-starter-oauth2-resource-server</artifactId> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-configuration-processor</artifactId> + <optional>true</optional> + </dependency> + <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java index a5342e554aec6296cb3f43ab0c3a3057de3da000..1046085e6a6dab222d2e1bab0efd0539a280dcee 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/config/CorsConfig.java @@ -38,7 +38,7 @@ public class CorsConfig { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins(domainProperty.domain()) - .allowedOrigins("http://localhost:5173") + .allowedOrigins("https://smartmat.app") .allowedMethods(Arrays.asList( HttpMethod.GET.name(), HttpMethod.POST.name(), diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java index 04f97f187ec4a7ccd3134760a71ac55bda5c749e..3623fbbb6d18fadd405f0e8283db8571dd11dd49 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/controller/ShoppingListController.java @@ -41,12 +41,12 @@ public class ShoppingListController { /** * Gets a shopping list by its ID * - * @param request the request containing the shopping list ID + * @param id the shopping list ID * @return the shopping list, or an error if the ID is invalid */ - @GetMapping("/{id}") - public ResponseEntity<ShoppingList> getShoppingListById(@RequestBody ShoppingListRequest request) { - Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListById(request.getGroupID()); + @GetMapping("shoppinglist/{id}") + public ResponseEntity<ShoppingList> getShoppingListById(@PathVariable("id") long id) { + Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListById(id); return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list)) .orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build()); } @@ -57,7 +57,7 @@ public class ShoppingListController { * @param request the request containing the group ID * @return the shopping list, or an error if the ID is invalid */ - @GetMapping("/group/{id}") + @GetMapping("/group/shoppinglist") public ResponseEntity<ShoppingList> getAllShoppingListsByGroupId(@RequestBody ShoppingListRequest request) { Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListByGroupId(request.getGroupID()); return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list)) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index bef07f681b183f9b50471f2a6970a5798388072e..c142e57334809622457af168da4530f31fd2e289 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -14,6 +14,9 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialec # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update +# Set CORS configuration origin address +domain.domain=https://smartmat.app + ## info # Hostname: dpg-cgv5710dh87i4q0fd1b0-a diff --git a/target/classes/application.properties b/target/classes/application.properties index ba7e37ce97efe8800019b8643c642a1f1746bca4..dad35a77d0ebba3f78f63458726661b8e48f6927 100644 --- a/target/classes/application.properties +++ b/target/classes/application.properties @@ -14,6 +14,8 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialec # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update + + ## info # Hostname: dpg-cgv5710dh87i4q0fd1b0-a @@ -23,4 +25,9 @@ spring.jpa.hibernate.ddl-auto = update # Password: Eyhs1OJxyZC56NQCrV7yAolEk9AkLAsC # Internal Database URl (from render): postgres://smartmat_user:Eyhs1OJxyZC56NQCrV7yAolEk9AkLAsC@dpg-cgv5710dh87i4q0fd1b0-a/smartmat # External Database URL: postgres://smartmat_user:Eyhs1OJxyZC56NQCrV7yAolEk9AkLAsC@dpg-cgv5710dh87i4q0fd1b0-a.frankfurt-postgres.render.com/smartmat -# PSQL Command: PGPASSWORD=Eyhs1OJxyZC56NQCrV7yAolEk9AkLAsC psql -h dpg-cgv5710dh87i4q0fd1b0-a.frankfurt-postgres.render.com -U smartmat_user smartmat \ No newline at end of file +# PSQL Command: PGPASSWORD=Eyhs1OJxyZC56NQCrV7yAolEk9AkLAsC psql -h dpg-cgv5710dh87i4q0fd1b0-a.frankfurt-postgres.render.com -U smartmat_user smartmat + +# Run spring boot locally/network-wide +# Uncomment to run network-wide. +#server.address=0.0.0.0 +#server.port=8080 \ No newline at end of file