Hallo liebes Forum,
ich habe ein Problem, bei dem ich trotz Google suche einfach nicht weiter komme. Der Titel sagts bereits:
CORS!
Zu meinem Vorhaben:
Ich habe eine SPS, vor der ich Daten lesen möchte und über eine HTML seite ausgeben möchte.
Die SPS ist eine Beckhoff CX9020, der Datenaustausch läuft über ADS, genauer gesagt. TcAdsWebService.
dazu habe ich mir ein Beispielprogramm von der Beckhoff Homepage runter geladen und das ganze ausprobiert.
Jetzt hänge ich bei dem Zugriff auf die SPS..
<!DOCTYPE html>
<html>
<head>
<title>TcAdsWebService.js Sample01</title>
<script type="text/javascript" src="/TcAdsWebService.js"></script>
<script type="text/javascript">
(function () {
var NETID = "5.36.137.149.1.1"; // Empty string for local machine;
var PORT = "801"; // PLC Runtime
var SERVICE_URL = "http://172.22.22.110/TcAdsWebService/TcAdsWebService.dll"; // HTTP path to the TcAdsWebService;
var ServiceUser = "Administrator";
var ServicePassword = "1";
var client = new TcAdsWebService.Client(SERVICE_URL, ServiceUser, ServicePassword);
var general_timeout = 500;
var readLoopID = null;
var readLoopDelay = 500;
var readSymbolValuesData = null;
// Array of symbol names to read;
var handlesVarNames = [
"MAIN.byteValue",
"MAIN.wordValue",
"MAIN.dwordValue",
"MAIN.sintValue",
"MAIN.intValue",
"MAIN.dintValue",
"MAIN.realValue",
"MAIN.lrealValue"
];
Alles anzeigen
die index.html datei liegt in QWeb.
Der Browser (egal ob Firefox, Edge oder Opera) sagt mir leider
"Access to XMLHttpRequest at 'http://Administrator:1@172.22.22.110/TcAdsWebService/TcAdsWebService.dll' from origin 'http://172.22.22.8' 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."
Die Apache.conf habe ich schon abgeändert, jedoch ohne Erfolg.
Hier meine Config:
#ServerType standalone
ServerRoot "/usr/local/apache"
Mutex file:/var/lock/ default
PidFile /var/lock/apache.pid
#ScoreBoardFile /usr/local/apache/logs/apache.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 800
KeepAliveTimeout 15
ServerLimit 32
StartServers 3
MaxClients 1024
MinSpareThreads 32
MaxSpareThreads 120
ThreadsPerChild 64
MaxRequestsPerChild 4000
Listen 80
User httpdusr
Group administrators
ServerAdmin admin@NAS
#ServerName NAS
TraceEnable off
ServerTokens Prod
DocumentRoot "/share/Web"
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory "/share/Web">
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST,GET,OPTIONS,DELETE,PUT"
Header always set Access-Control-Max-Age "3600"
Header always set Access-Control-Allow-Headers "Content-Type,Authorization"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
</Directory>
Include /etc/config/apache/extra/apache-default-modules.conf
<IfModule headers_module>
Header always append X-Frame-Options SAMEORIGIN "env=!share-iframe"
Header always edit Set-Cookie ^(.*)$ $1;HttpOnly
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
Satisfy All
</FilesMatch>
UseCanonicalName Off
HostnameLookups Off
<Directory "/usr/local/apache/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
ErrorLog /dev/null
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel crit
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
</IfModule>
#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule alias_module>
Alias /v3_menu/ "/home/httpd/v3_menu/"
<Directory "/home/httpd/v3_menu">
AllowOverride None
Require all granted
</Directory>
</IfModule>
<IfModule autoindex_module>
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>
#
# Document types.
#
<IfModule mime_module>
TypesConfig /etc/config/apache/mime.types
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .ee
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage he .he
AddCharset ISO-8859-8 .iso8859-8
AddLanguage it .it
AddLanguage ja .ja
AddCharset ISO-2022-JP .jis
AddLanguage kr .kr
AddCharset ISO-2022-KR .iso-kr
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddCharset ISO-8859-2 .iso-pl
AddLanguage pt .pt
AddLanguage pt-br .pt-br
AddLanguage ltz .lu
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .sv
AddLanguage cs .cz .cs
AddLanguage ru .ru
AddLanguage zh-TW .zh-tw
AddCharset Big5 .Big5 .big5
AddCharset WINDOWS-1251 .cp-1251
AddCharset CP866 .cp866
AddCharset ISO-8859-5 .iso-ru
AddCharset KOI8-R .koi8-r
AddCharset UCS-2 .ucs2
AddCharset UCS-4 .ucs4
AddCharset UTF-8 .utf8
<IfModule negotiation_module>
LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
</IfModule>
AddType application/x-tar .tgz
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
AddHandler cgi-script .cgi
AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler send-as-is asis
AddHandler imap-file map
AddHandler type-map var
</IfModule>
<IfModule mime_magic_module>
MIMEMagicFile /etc/config/apache/magic
</IfModule>
<IfModule setenvif_module>
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<IfModule reqtimeout_module>
RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>
Include /etc/config/apache/extra/apache-ssl.conf
Include /etc/config/apache/extra/apache-fastcgi.conf
Include /etc/config/apache/extra/apache-http-compress.conf
Include /etc/config/apache/extra/apache-musicstation.conf
Include /etc/config/apache/extra/apache-photo.conf
Include /etc/config/apache/extra/apache-video.conf
Include /etc/config/apache/extra/apache-dav-proxy.conf
Alles anzeigen
Mein System ist ein TS-453BE mit aktueller Firmware 4.5.1_20201123
Kann mir von euch noch jemand helfen?
Fehlen noch Angaben?
Viele Grüße
Michael