try to fix cors
This commit is contained in:
@@ -10,10 +10,10 @@ import java.util.Optional;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class Routes {
|
public class Routes {
|
||||||
|
|
||||||
@GetMapping("/posts/{longitude}/{latitude}")
|
@GetMapping("/posts/{longitude}/{latitude}")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
public Vector<JodelPost> getPostsByLocation(@PathVariable("longitude") float longitude, @PathVariable("latitude") float latitude) {
|
public Vector<JodelPost> getPostsByLocation(@PathVariable("longitude") float longitude, @PathVariable("latitude") float latitude) {
|
||||||
// list of all posts (not comments) in range
|
// list of all posts (not comments) in range
|
||||||
Vector<JodelPost> posts = new Vector<>();
|
Vector<JodelPost> posts = new Vector<>();
|
||||||
@@ -121,6 +121,7 @@ public class Routes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/post/{id}")
|
@GetMapping("/post/{id}")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
public JodelPost getPostByID(@PathVariable("id") long id) {
|
public JodelPost getPostByID(@PathVariable("id") long id) {
|
||||||
// list of all posts (not comments) in range
|
// list of all posts (not comments) in range
|
||||||
Optional<JodelPost> root_post = Optional.empty();
|
Optional<JodelPost> root_post = Optional.empty();
|
||||||
@@ -226,6 +227,7 @@ public class Routes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/posts")
|
@PostMapping("/posts")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
public JodelPost postPost(@RequestBody JodelPost post) {
|
public JodelPost postPost(@RequestBody JodelPost post) {
|
||||||
// DB connection and statement
|
// DB connection and statement
|
||||||
Connection c;
|
Connection c;
|
||||||
@@ -300,6 +302,7 @@ public class Routes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/post/{id}")
|
@DeleteMapping("/post/{id}")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
public void deletePost(@PathVariable long id) {
|
public void deletePost(@PathVariable long id) {
|
||||||
// DB connection and statement
|
// DB connection and statement
|
||||||
Connection c;
|
Connection c;
|
||||||
|
|||||||
@@ -13,16 +13,4 @@ public class SwaJodelApplication {
|
|||||||
SpringApplication.run(SwaJodelApplication.class, args);
|
SpringApplication.run(SwaJodelApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public WebMvcConfigurer corsConfigurer() {
|
|
||||||
return new WebMvcConfigurer() {
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
registry.addMapping("/**").allowedOrigins("*");
|
|
||||||
registry.addMapping("/**").allowedOrigins("jodel.local.anxietyprime.de");
|
|
||||||
registry.addMapping("/**").allowedOrigins("jodel.anxietyprime.de");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user