• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing netPI web UI with REST API
#12
Dear Armin,

>you agree that a standard web browser you are using to access the netPI via netPI's web pages works well, or?

I expect the above.
I'm not an expert for html & JavaScript so that I am not 100% sure my code is correct.

Attachments:
- index_xml.html & app_xml.js: this is a sample code for rest api by function 'XMLHttpRequest'.
- index_fetch.html & app_fetch.js: this is a sample code for rest api by function 'fetch'.
- nodered_flows_test_purpose.json: this is a Node-RED flow

I found the following description in a Japanese local site:
"I think that recent Chrome does not allow access to local files through httpd"
Therefore, the REST API is called on Node-RED just as a trial.

All of the above codes output the following errors to 'Console' tab of DevTools.
- Access to fetch at 'https://netpi1/login' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
- POST https://192.168.3.56/login net::ERR_FAILED
- Uncaught (in promise) TypeError: Failed to fetch


Have you ever call REST API to netPI from an html?
As far as I searched in Internet contents, the server side must include 'Access-Control-Allow-Credentials: true' to be accessed from a client.
Because the above error seems to output by this reason???

Thank you very much for your support.
Best regards,


Attached Files
.zip   restapi.zip (Size: 2.73 KB / Downloads: 1)
  Reply


Messages In This Thread
Accessing netPI web UI with REST API - by Armin@netPI - September-5th-2018, 03:45 PM
RE: Accessing netPI web GUI with HTTP REST - by Armin@netPI - September-11th-2018, 06:51 AM
RE: Accessing netPI web GUI with HTTP REST - by tad - March-30th-2021, 02:50 AM
RE: Accessing netPI web GUI with HTTP REST - by tad - March-30th-2021, 07:18 AM
RE: Accessing netPI web UI with REST API - by Armin@netPI - March-30th-2021, 07:45 AM
RE: Accessing netPI web UI with REST API - by tad - June-10th-2021, 01:40 PM
RE: Accessing netPI web UI with REST API - by tad - June-25th-2021, 09:06 AM
RE: Accessing netPI web UI with REST API - by tad - June-28th-2021, 07:41 AM
RE: Accessing netPI web UI with REST API - by tad - June-30th-2021, 03:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  REST API server data communication MGharat 2 2,538 July-21st-2021, 07:01 AM
Last Post: MGharat
  Get host MAC via REST API inside container bschandra 4 3,772 November-16th-2020, 09:26 AM
Last Post: bschandra
  Accessing a modbus device connected to RTE port from Node-RED tad 10 8,228 October-2nd-2020, 07:21 AM
Last Post: Armin@netPI
  Web browser reports "insecure connection" when accessing netPI for the first time Armin@netPI 2 2,874 January-31st-2020, 07:07 AM
Last Post: Armin@netPI
Information netPI Docker REST API patrick 1 3,467 July-16th-2019, 02:45 PM
Last Post: patrick
  Accessing Docker daemon through remote CLI adeeljsid 2 3,559 August-30th-2018, 12:32 PM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)