fix: fix cors again

This commit is contained in:
Sosokker 2025-02-02 09:29:58 +07:00
parent c7e5ee6d30
commit 3d44f74d94
3 changed files with 26 additions and 19 deletions

View File

@ -6,23 +6,28 @@ server {
listen 80;
server_name localhost;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
add_header 'Content-Type' 'application/json';
add_header 'Content-Length' 0;
return 204;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
proxy_pass http://backend:8080;
}

View File

@ -12,11 +12,13 @@
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 1.5rem;
text-align: center;
max-height: 650px;
}
#table-section {
overflow-x: auto;
overflow-y: auto;
max-height: 500px;
}
#map {

View File

@ -40,7 +40,7 @@
}
</script>
<div id="statistic">
<h2>Rainfall Statistics</h2>
<h2>Rainfall Statistics | Rain map</h2>
<p>Today rain/hr.</p>
<div id="table-section">
<script>
@ -104,7 +104,7 @@
const lat = weatherData.map((location) => location.coord.lat);
const text = weatherData.map(
(location) =>
`${location.name}: ${location.rain["1h"]} mm/hr (${location.weather[0].description})`
`${location.name}: ${location.rain["1h"]} mm/hr)`
);
const data = [