Skip to content
Snippets Groups Projects
Commit accbd2fd authored by Anders Austlid's avatar Anders Austlid
Browse files

Small corrections in shoppinglist endpoint, changed cors origin

parent e1565212
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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(),
......
......@@ -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))
......
......@@ -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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment