ソースを参照

🐛 set proxy properly

Oversomes CORS limitations
jmacura 3 年 前
コミット
4ec59aca10
1 ファイル変更8 行追加1 行削除
  1. 8 1
      src/app/irrigation/irrigation-forecast.service.ts

+ 8 - 1
src/app/irrigation/irrigation-forecast.service.ts

@@ -6,6 +6,13 @@ export class IrrigationForecastService {
   constructor(private httpClient: HttpClient) {}
 
   getForecast() {
-    return this.httpClient.get('https://www.gis.atapex.sk/agrihub_forecast/');
+    const crossOrigin = !window.location.hostname.includes('gis.atapex.sk');
+    const proxyPath = window.location.hostname.includes('localhost')
+      ? 'http://localhost:8085/'
+      : '/proxy/';
+    return this.httpClient.get(
+      (crossOrigin ? proxyPath : '') +
+        'https://www.gis.atapex.sk/agrihub_forecast/'
+    );
   }
 }