My goal is to access the Kit project running on the server from a mobile device.
I have tried to configure the server under the local settings to my IPv4 (and made sure that all required ports are open).
If the server is filled in as a URL or the server’s IPv4,console will output :
xxx.cn/:1 Access to fetch at 'http://xxx/' from origin 'http://xxx.cn' has been blocked by CORS policy: Method OPTIONS is not allowed by Access-Control-Allow-Methods in preflight response.
If the server is set to localhost or 127.0.0.1 , then:
index.js:2 WebSocket connection to 'ws://127.0.0.1:49100/sign_in?peer_id=peer-6621654090&version=2' failed:
Yes, unfortunately, I believe this streaming system is not designed for WAN applications like this. Just for LAN. Just local area networks. Your mobile device my not be able to receive this stream. However, I will check with the dev team.
Just for additional options, I asked ChatGPT about this and I got the following reply. It may be worth a look.
The error you’re encountering is related to CORS (Cross-Origin Resource Sharing) policy. Here’s a breakdown of the issue and how to resolve it:
Error Explained
Preflight Request:
When your application sends a cross-origin request (e.g., from http://xxx.cn to http://xxx), the browser first sends an OPTIONS request (preflight) to check if the server allows the actual request method (e.g., GET, POST).
The server must respond to this OPTIONS request with appropriate CORS headers.
Cause of the Error:
The server’s CORS policy does not include the OPTIONS method in the Access-Control-Allow-Methods header of its preflight response.
This blocks the browser from proceeding with the actual request.
Solution Steps
Update Server CORS Configuration:
Ensure the server explicitly allows the OPTIONS method in its response header:
makefile
Copy code
Access-Control-Allow-Methods: GET, POST, OPTIONS
Example server configuration for Node.js with Express:
If using a framework or middleware to handle CORS (e.g., Flask-CORS, Django-CORS, or CORS plugins in NGINX/Apache), ensure it includes OPTIONS in the allowed methods.
Debug Preflight Response:
Use browser developer tools or tools like curl or Postman to inspect the preflight OPTIONS response. Ensure:
Access-Control-Allow-Methods includes OPTIONS.
Access-Control-Allow-Origin matches or is set to *.
Check Server Logs:
Look at the server logs to confirm that the OPTIONS request is being received and processed correctly.
Temporary Workaround (Not Recommended for Production):
You can disable CORS checks in your browser for testing purposes (e.g., using browser flags or plugins). However, this should never be used in production as it compromises security.
Example Response Headers for CORS
A correct preflight response should look like this:
mathematica
Copy code
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type
Thank you Richard, I have a few more questions, such as how to configure the ‘stream’ in stream.config. If it’s set up correctly, would the server.source work over a LAN? Since I’m only using one server for a POC, I don’t want to use the DOCKER+K8S scenario for such a small-scale test—it’s too complicated for me.
It should definitely be able to work over a LAN for computer to computer yes. I am not sure about the special requirements for computer to mobile though. That may not work as expected. It should if your mobile device is connected on the same LAN wifi and you configure it well. I would start with computer to computer first and go from there.
Could you please ask the developers to confirm: Does the git repository only support local networks, and is it true that to truly support LAN, Kubernetes plus Docker must be used?
The example code in Kit and Kat is for local networks only, yes, or for remote machines that are set up like local networks, such as usual vpns, proxies etc. This is because our example code does not have the advanced ability to navigate through NATS and complex network to network scenarios.
No, you do not need to use dockers or Kubernetes to take advantage of local networks.