Open gwang1224 opened 11 months ago
Issue: Cors error from server to server, server to deployed, deployed to deployed
CORS error (Cross-Origin Resource Sharing error) occurs when a web page tries to request data from a different domain than the one that served the web page. To fix it, the server must include specific headers in its response, such as Access-Control-Allow-Origin, to indicate which origins are allowed to access its resources.
When running server to server, the error occurs when a web application, running at one origin (in this case, 'http://127.0.0.1:4000/'), tries to request a different origin ('http://localhost:8085/') that doesn't explicitly allow such requests.
This code handles CORS (Cross-Origin Resource Sharing) preflight requests. Requests are HTTP OPTIONS requests are sent by the browser to check whether a cross-origin request is allowed by the server before making the actual request.
Access-Control-Allow-Origin: Specifies which origins are allowed to access the resource. In this case, it allows any origin by using the asterisk symbol(*).
if ($request_method = OPTIONS ) { add_header "Access-Control-Allow-Headers" "access-control-allow-origin, access-control-allow-credentials, Content-Type, Authorization, x> add_header "Access-Control-Allow-Credentials" "true"; add_header "Access-Control-Allow-Origin" "*"; add_header "Access-Control-Allow-Methods" "GET, POST, PUT, DELETE, OPTIONS, HEAD"; add_header "Access-Control-Allow-MaxAge" 600; return 200; }
In our backend files, which include AllStorting.java, FibonacciController.java, I added
@CrossOrigin(origins="https://ige-csa.github.io/")
This is used by Spring application to enable Cross-Origin Resource Sharing (CORS) for a specific controller or method. The specified origin (https://ige-csa.github.io/) is allowed to make cross-origin requests to the controller or method.
1. Implementation changes
Original Ideation & Design
2A. SORTING: Key Accomplishments
ABSTRACT CLASS: Abstract base class defining the common structure for sorting algorithms
![image](https://github.com/IGE-CSA/Issues/assets/104966589/7837bd94-3b99-4dbb-a928-3ba810f7b521)INHERITANCE: Concrete subclass inherits common behavior from abstract class while providing specific implementations for each sort method
Merge
![image](https://github.com/IGE-CSA/Issues/assets/104966589/4548bfa2-64c2-41da-89d2-e21fb8917880)Insertion
![image](https://github.com/IGE-CSA/Issues/assets/104966589/1ed16c65-f234-4bfc-8501-0bfe76e7d7ce)Bubble
![image](https://github.com/IGE-CSA/Issues/assets/104966589/868204e7-bc8e-4ee7-a191-4564bcb3de0b)Selection
![image](https://github.com/IGE-CSA/Issues/assets/104966589/528909af-abb2-40d1-b63a-8a3bf37442f0)
Preform sorting calculations & return results as a map
- Returns speed, num of swaps/iterations/comparisons - Averaged the results for each Sort 12 times with 10,000 random elements ![image](https://github.com/IGE-CSA/Issues/assets/104966589/c674bc23-8554-4449-95ec-2909a6d9f294)Generated data
![image](https://github.com/IGE-CSA/Issues/assets/104966589/b511a222-13f8-41ed-aed3-5fb4c7080c99)2B. FIBONACCI: Key Accomplishments
API Controller
- 2 additional methods to solve nth result ![image](https://github.com/IGE-CSA/Issues/assets/104966589/fbbb5241-0043-4004-8c69-98d90b576c30)Binet
![image](https://github.com/IGE-CSA/Issues/assets/104966589/49ffa7a1-d60c-4717-99ef-e397e00a6f25)Matrix
![image](https://github.com/IGE-CSA/Issues/assets/104966589/07e03e1a-e4c6-4e83-8875-01e73acf3459)Generating key info (fib num & time)
![image](https://github.com/IGE-CSA/Issues/assets/104966589/65a6188f-bcfb-47e8-9bf5-ba34f48cbb8d)