I have a cordova app running on angular that uses a sails server as its API endpoint. It is set up to use CORS and everything is working with ajax calls.
I am attempting to connect to the sails server using socket.io. I copied the sails.io.s file from the sails server's assets folder to the cordova app. I modified it so that it connects to 127.0.0.1:1337 and does so successfully. It does not use cookies on the front end and the sails end does not use socket authorization (set in config/sockets.js).
When I call:
io.socket.get('/controller/action', function callback(return){
});
The return object looks something like this:
{
message: "TypeError: Object #<Object> has no method 'get'",
status: 500
}
The sails server log doesn't show that it is hitting /controller/action. Does anyone have any experience with using the custom sails io library on a JS client that isn't sails?
Related
I'm able to verify the webhook using glitch from the getting started:
https://glitch.com/edit/?fbclid=IwAR2YTjZuGGM9Hi6T_v1eZh_nV6_HY3RYn_8lll4gY1REa_bJy6ZAuq6tkKQ#!/whatsapp-cloud-api-echo-bot
my local server (in a subdomain with https enabled) has the same behavior as glitch and show "WEBHOOK_VERIFIED" on the log for the request:
/webhook?hub.mode=subscribe&hub.verify_token=xpto123&hub.challenge=123
but when try to verify my local server the request from meta does not reach the server.
chrome showing that the connection to the server is secured
After more tests I found that my local server was been blocked by the ISP, understood it after test with another connection.
I made my own server and had tried ngrok and other programs to run it from local host with https redirect but whatsapp doesn't allow the use of those programs.
In the end, my error was that the URL HAS to end in /webhook or else, it won't even send the request. Then it'll send a GET request and you have to return the hub.challenge query param after making sure that the provided token from them is the one you set up. This is my code using NodeJS
if(req.query['hub.verify_token'] === process.env.VERIFY_TOKEN) return res.status(200).send(req.query['hub.challenge'])
I'm trying out the communication between my backend / frontend. The application is developed in react native and my backend is based on spring boot. When I run my application in my phone through the Expo Go app I can't send http requests to my backend (it works with postman at: localhost:8080/user).
When I try to do the same requests in my application I have defined the following function:
export function signup(signupRequest) {
return fetch({
url: "192.168.10.152:8080" + "/user",
method: "POST",
body: JSON.stringify(signupRequest)
});
}
And then I get the following error:
[Unhandled promise rejection: TypeError: Network request failed]
at node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0
If it helps I run my backend on ubuntu 20.04 and I got my local ip with the command
ip a
Update, I have no updated my application.properties in my spring-boot project like this:
server.address=192.168.10.152
server.port=8080
I still get the same error when I try to make a post-request from my react native application however.
I tried to push my backend to the domain with https protocol and everything was ok. There's an application, ngrok that allows you to send requests to a server but using other link with https protocol.
For example, if you have your backend server on localhost:5000, then you need to open ngrok command line and integrate your server with ngrok http 5000 command. As the result you'll get a link that will look like this:
https://f971-31-128-76-233.eu.ngrok.io
I have 2 servers which are API server and Client server ....
Both server using Google Cloud server and I use Laravel framework to develop my system...
So, currently the problem is, it return 403 error when calling API (to API server) using GuzzleHttp (from Client Server).....
But after I change the user agent to curl/7.65.3, suddenly it is working fine...
But I want to know why??? Is there any other solution without changing the user-agent???
Thanks
What is your use method? If GET you can refer to:
GET Requests That Include a Body
If a viewer GET request includes a body, CloudFront returns an HTTP status code 403 (Forbidden) to the viewer.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html
I'm developing an app using Angular for client side and Django for server side. During development I'm running Django in port 8000 for managing all API requests, and serving my client app using Angular CLI running at port 4200.
Sending GET requests to Django work w/o problems but when I try to send a POST request that includes some cookies with session information, it fails as the cookies are not included in the header.
I know that the source of this "problem" is the CORS issue [read more here] and that it won't be a problem in production as both client and server apps will be running in the same server and port, however I wonder how can I fix this situation at least for development.
I've tried using the django-cors-headers module with the options CORS_ALLOW_CREDENTIALSand CORS_ORIGIN_ALLOW_ALL set to True but it didn't work.
Any ideas?
Finally I managed to make all work.
I thought it was a problem of Django so I installed django-cors-headers module, however the "problem" is in the browser (actually is not a problem, it is a security issue, see [here][1]).
Anyway, I solved the problem using a proxy rule for my Angular CLI, as follows:
First, instead of sending my requests to http://localhost:8000/api/..., I send them to /api/ (i.e. to my Angular server running at port 4200).
Then I added a file in my Angular project called "proxy.conf.json" with the following content:
{
"/api": {
"target": "http://localhost:8000",
"secure": false
}
}
Finally, I added the flag "--proxy-config" to the Angular CLI server:
ng serve --watch **--proxy-config proxy.conf.json**
Now, all API requests are sent to the port 4200 and Angular internally redirects them to Django, avoiding the CORS problem.
Note: With this solution I didn't need anymore the django-cors-headers module.
I have a server on heroku, using https certificate. Now I am trying to build an IOS/Android app using Ionic framework and make connection to that heroku server.
The error when I do it is
"ERR CONNECTION REFUSED" when I am trying to do https://example.com/auth
And when I change it to http instead, the error is
XMLHttpRequest cannot load http://example.com/auth. The request was redirected to 'https://www.example.com/auth', which is disallowed for cross-origin requests that require preflight.
Thanks for any help.