Code Monkey home page Code Monkey logo

Comments (8)

mdzio avatar mdzio commented on May 30, 2024

Der eine Header könnte relativ schnell eingebaut werden.
Laut MDN web docs müssen wohl auch sogenannte Preflight Requests (HTTP-Methode OPTIONS) unterstützt werden, wenn die HTTP-Methode PUT verwendet werden soll.

from ccu-jack.

mdzio avatar mdzio commented on May 30, 2024

In der Standardkonfiguration werden nun alle anfragenden Quellen zugelassen (Access-Control-Allow-Origin: *). Falls die Authentifizierung eingeschaltet ist (s.a. Kommandozeilenoptionen -user und -password) muss die Anfragequelle explizit zugelassen werden (s.a. CORS-Spezifikation). Dies erfolgt mit der Kommandozeilenoption -cors.
Beispiel: Die Web-Applikation auf dem Host https://example.com soll mit Authentifizierung auf die VEAP-API zugreifen können. Dafür muss die Kommandozeilenoption -cors https://example.com gesetzt werden.
Preflight Requests werden ebenfalls unterstützt.

from ccu-jack.

 avatar commented on May 30, 2024

Ich bekomme via Web-Anwendung leider noch immer die Fehlermeldung Access to XMLHttpRequest at 'https://***:2122/' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource..
Daten lassen sich nur mit einem Workaround abrufen: Authentifizierung abschalten und im Get-Request den Header 'Content-Type' auf 'text/plain' setzen (also nur ein Simple Request laut https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests). Sobald ich den Header 'Content-Type' auf 'application/json' setze oder einen Authentifizierungsheader setze, schlägt der Preflight-Request (OPTIONS) fehl mit Status Code 403. Die CORSOrigins in der ccu-jack.cfg sind entsprechend konfiguriert.
Ich nutze CCU-Jack in der Version 2.0.48
cors_error_samples.zip

from ccu-jack.

mdzio avatar mdzio commented on May 30, 2024

Danke für das Beispiel. Das Ergebnis ist bei mir das gleiche.

Allerdings sieht es wohl so aus, dass CORS nur für das HTTP(S)-Protokoll und nicht für das File-Protokoll (file://) spezifiziert ist.

Wenn Du aber Dein Beispiel in den Ordner webui\custom im CCU-Jack-Installationsverzeichnis kopierst, apiUrl = '/' setzt und dann das Beispiel mit https://<CCU-Jack-IP>:2122/ui/custom/cors_error_samples.html aufrufst, dann sind alle 3 Tests erfolgreich. Wahrscheinlich klappt es auch mit jedem beliebigen anderen Web-Server.

from ccu-jack.

 avatar commented on May 30, 2024

Danke für die Anregung, den CCU Jack Web-Server zu verwenden. Ich konnte es damit auch erfolgreich testen. Von einem anderem Web-Server tritt das Problem jedoch weiterhin auf. Habe dieses Beispiel auf meinem NAS laufen: https://ip-nas/cors_error_samples.html --> Fehler wie bereits oben beschrieben.
Das Problem tritt auch aus einer Angular Anwendung auf, welche in einem Docker Container auf Basis des Nginx Images gehostet ist.

from ccu-jack.

mdzio avatar mdzio commented on May 30, 2024

Die Header Content-Type und Authorization lassen wohl CORS fehlschlagen. Ich werde für die beiden Header mal eine Ausnahme einbauen.

from ccu-jack.

mdzio avatar mdzio commented on May 30, 2024

Erste Tests sehen gut aus. Der CORS-Zugriff wird ebenfalls für HTML-Dateien aus dem Dateisystem (file://) funktionieren, wenn die CORS-Konfiguration folgendermaßen gesetzt wird:

"CORSOrigins": [
      "null"
    ],

from ccu-jack.

 avatar commented on May 30, 2024

Vielen Dank! Klappt wunderbar - auch aus einer Angular Anwendung heraus, die auf einem anderen Webserver läuft

from ccu-jack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.