PLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. alitera
  2. PLCnext Technology & PLCnext Controls
  3. Friday, 23 August 2019

Hi, habe mir heute den Sourcecode herunter geladen.

https://github.com/PLCnext/HTML5_with_REST

Nutze gerade die Firmware 2019.3 und auch PLCnext Engineer 2019.3

Das Steuerungsprogramm aus Projekt läuft und die Simulation zeigt Werte an.

Dann habe ich mir den Javascript Sourcecode vorgenommen. Die HTML Seite geht im Browser auf und ich könnte USER / Passwort eingeben zum Authentifizieren.

Dann passiert aber nichts weiter. Wenn ich mir im Google Chrome nur den Profiler anschaue, dann zeigt er folgenden Fehler an.

Access to XMLHttpRequest at 'http://192.168.10.10/_pxc_api/auth/auth-token' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
pxcapiclient.js:189 POST http://192.168.10.10/_pxc_api/auth/auth-token net::ERR_FAILED

in der Github Beschreibung steht leider nichts.

Was kann ich tun?

Danke!

Alex.

 

 

 

 

 

alitera Accepted Answer Pending Moderation
0
Votes
Undo
Hi, I downloaded the source code today.

https://github.com/PLCnext/HTML5_with_REST

Use just the firmware 2019.3 and also PLCnext Engineer 2019.3

The control program from the project is running and the simulation shows values.

Then I made the javascript source code. The HTML page goes into the browser and I could enter USER / password to authenticate.

Then nothing happens. If I only look at the Profiler in Google Chrome, it shows the following error.

Access to XMLHttpRequest at 'http://192.168.10.10/_pxc_api/auth/auth-token' from origin 'null' has been blocked by CORS policy: Redirect is not allowed for a preflight request.
pxcapiclient.js: 189 POST http://192.168.10.10/_pxc_api/auth/auth-token net :: ERR_FAILED

in the Github description is unfortunately nothing.

What can I do?

Thank you!

Alex.
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Alex

I’m not very familiar with cross-origin requests, but does any thing in this page help?

https://developer.chrome.com/extensions/xhr

- Martin

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

alitera Accepted Answer Pending Moderation
0
Votes
Undo

Hi Martin,

thank you for the information regarding the CORS policy. It seems that first I should transfer the web page to the web server of the PLC 2153 controller :)

I tried it from my local PC Webserver :)

Folder of the Webserver: /var/www/plcnext

I have make a directory ehmi. 

mkdir ehmi

--> chmod --> folder  write / read access 

Then I have transfered all the necessary files to the folder ehmi.

When I trying to test for example https://192.168.10.10/ehmi/HMIDemo.html then the controller redirect to the welcome page.

Do you have an idea, what is the reason for that?

Thanks a lot.

Alex

 

 

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Alex,

You may need to configure the NGINX web server on the PLC.

Again, I'm not too familiar with the NGINX server but here is a page that might give some useful tips:

https://www.linode.com/docs/web-servers/nginx/how-to-configure-nginx/

... in particular, the "location" block in the nginx configuration file might need to be edited.

- Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

alitera Accepted Answer Pending Moderation
0
Votes
Undo

Hi Community, I found my mistake.

I though, that I have to transfer the HMIDemo.html Webpage and the folders /img /js /css to the nginx Webserver folder: /var/www/plcnext

But this is wrong.

The correct folder is this:

/opt/plcnext/projects/PCWE/Services/Ehmi/ehmi/

 

You don´t need to disable the redirection of Webpages (/etc/nginx/nginx.conf)!

 

With the picture below, you can see - It is working fine, now ?

WebAPP.PNG

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

That's excellent news, thank you for sharing!

If you are happy to prepare a step-by-step guide to how you got this working, it would make a great Makers Blog post.   :-)

Martin.

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.