capcom6/android-sms-gateway

405 Not Allowed

Closed this issue · 4 comments

Trying to do POST request im getting 405 Not Allowed. Get is alright.

Please provide more details about the problem:

  1. App version.
  2. App mode (e.g., local, private, cloud).
  3. Request details: URL, headers, body, etc.
  4. Source of the API documentation for this request.
  1. 1.16.2 / Build 755
  2. Both local and cloud
  3. curl -X POST -u user:passwd -H "Content-Type: application/json" -d '{"message": "test", "phoneNumbers": ["+48571404069"]}' https://sms.capcom.me:443
    curl -X POST -u user:passwd -H "Content-Type: application/json" -d '{"message": "test", "phoneNumbers": ["+48571404069"]}' http://10.120.125.100:8080
  4. Readme.md
  5. Response from cloud:
<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.27.0</center>
</body>
</html>
  1. RAW response (local)
    HTTP/1.1 405 Method Not Allowed
    connection: keep-alive
    content-length: 0
    date: Wed, 31 Jul 2024 08:05:54 GMT
  2. Access to XMLHttpRequest at 'http://192.168.100.53:8080/' from origin 'http://localhost:4200' 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. (different ip due to different local network)

There appears to be an incorrect path in your example request. For sending messages in the case of local mode, you should use /message as the path, while in cloud mode, you should use /api/3rdparty/v1/message according to the documentation. Can you please provide a screenshot of the README.md file part, where there is a POST request without a path?

Regarding the CORS (Cross-Origin Resource Sharing) issue, it is not allowed by design for security reasons. To resolve this, you should proxy your requests through a backend server. This ensures that the request is made from a trusted source and helps prevent unauthorized access.

It seems I made this mistake. After using /message in the path it worked. The README part I used for this request does indeed have /message in the path. I removed it by mistake.