3 Answers
- Newest
- Most votes
- Most comments
3
Hi jjshen,
Please go through the below steps i hope it will helps to resolve your issue.
Configure CORS in Spring Boot:
- Ensure your Spring Boot application includes CORS headers.
@RestController
public class MyController {
@CrossOrigin(origins = "https://mydns.com")
@RequestMapping("/course/listAllCourse")
public ResponseEntity<?> listAllCourses() {
// Your code here
}
}
CORS Configuration Class (if needed):
- Add a global CORS configuration if individual controllers are not sufficient.
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("https://mydns.com")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowCredentials(true);
}
}
Check ALB Listener Rules:
- Ensure the ALB listener is correctly forwarding HTTPS traffic to the Spring Boot backend.
- ALB itself doesn't manage CORS, but ensure SSL/TLS termination is correctly set up.
Validate SSL/TLS:
- Verify that your certificates are correctly imported and configured on both the ALB and the Spring Boot application.
Testing:
- Test the CORS configuration by making an API request from your Vue.js application to ensure the Access-Control-Allow-Origin header is correctly returned.
3
You cant perform Header Insertion/modification with an ALB. You will need to rectify this on your HTTP server
Relevant content
- asked 5 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 days ago
Thank you very much for your answer. I resolve this problem.