PHP Rocks
Wieder mal CORS/frames - Druckversion

+- PHP Rocks (https://www.php-rocks.de)
+-- Forum: HTML, CSS, Usability und Barrierefreiheit (https://www.php-rocks.de/https://www.php-rocks.de/forum/11-html-css-usability-und-barrierefreiheit.html)
+--- Forum: JavaScript / JavaScript Frameworks / Ajax (https://www.php-rocks.de/https://www.php-rocks.de/forum/13-javascript-javascript-frameworks-ajax.html)
+--- Thema: Wieder mal CORS/frames (/https://www.php-rocks.de/thema/111-wieder-mal-cors-frames.html)



Wieder mal CORS/frames - Till - 13.09.2016

Möchte eine Seite im frame aufrufen:
Zitat:XMLHttpRequest cannot load api.webfan.de/api-d/4/js-api/library.js?plugin=alertify. The 'Access-Control-Allow-Origin' header has a value 'http://domainundhomepagespeicher.webfan.de' that is not equal to the supplied origin. Origin 'frdl.webfan.de' is therefore not allowed access.
my-apps.297.html:1 XMLHttpRequest cannot load api.webfan.de/api-d/4/js-api/library.js?plugin=hash. The 'Access-Control-Allow-Origin' header has a value ' domainundhomepagespeicher.webfan.de' that is not equal to the supplied origin. Origin 'frdl.webfan.de' is therefore not allowed access.

Dabei habe ich:
PHP-Code:
public static function originHeaders(){
    
header("Access-Control-Allow-Credentials: true");        
    
header("Access-Control-Allow-Origin: ".((isset($_SERVER['HTTP_ORIGIN'])) ? $_SERVER['HTTP_ORIGIN'] : "*"));
    
header("Access-Control-Allow-Headers: X-Requested-With"); 
// NUR EINSCHRÄNKUNG * GEHT NICH ! header('X-Frame-Options: ALLOW-FROM *'); */
//header('X-Frame-Options: ALLOW-FROM http://shell.frdl.de');
    //header_remove("X-Frame-Options"); 
if(isset($_SERVER['HTTP_ORIGIN'])){
    
header('X-Frame-Options: ALLOW-FROM '.$_SERVER['HTTP_ORIGIN']);
}else{
    
header_remove("X-Frame-Options"); 
}
    
header_remove("X-Frame-Options"); 
    
    
header("Vary: Origin");             
 } 
Komischerweise ging es vorher mit header_remove("X-Frame-Options"); , sollte ich die Variante mit X-Frame-Options: ALLOW-FROM verwenden?
Im Firefox funktioniert es, im Opera gibt es diesen Security error, mh?
domainundhomepagespeicher.webfan.de/cdn/application/webfan/app.html#/com.webfan.my/browse/http:~2F~2Ffrdl.webfan.de~2Fmy-apps.297.html


RE: Wieder mal CORS/frames - Till - 17.09.2016

Scheint ein Bug!?
https://bz.apache.org/bugzilla/show_bug.cgi?id=51223
Der Fehler tritt auf beim status code 304, dies bewirkt beim Apache das KEINE Cors header gesendet werden.

Als Workaround sende ich nun einen extra-request-header und antworte darauf mit 204 statt mit 304.
Das gefällt mir gar nicht! Hat jemand eine bessere Idee?

Es gibt einen Patch für ubuntu https://bz.apache.org/bugzilla/attachment.cgi?id=27027
Ich benutze debian, habe aber i.M. keinen Plan wo ich den Patch einfügen könnte, ich finde keine entsprechende .cnf?