Rails app not responding to Postman requests - ruby-on-rails

My locally running rails app (on localhost:3000) responds to requests in the browser or from curl, but is not responding to requests from the desktop postman client, which immediately gives the generic "Could not get any response". Any idea what could be causing this?

For this you can use NGROK. It provides you a tunnel which can easily be used with postman or anyother such service. Download the library from here and run the tunnel as
./ngrok http 3000
or you can use lvh.me:3000 if your request is from same machine.

Related

How to use ngrok with puma-dev rails server

My rails app is spin up using puma-dev on Ubuntu.
I'm using puma-dev command to start my app (in foreground) and then access the rails app using
https://app.test:9283.
As the puma-dev is running in the foreground I have to use the port 9283 to access the port.
Now I want to access the rails app on remote machines like a mobile device or other PC. So have to use the ngrok to do so. I have installed ngrok in my ubuntu but I'm not able to access my localhost setup running on https://app.test:9283 using ngrok. Any help would be appreciated!
NOTE: When I use ./ngrok http 80 it successfully redirects me to localhost:80 which means ngrok is working properly.
With puma-dev it is necessary to include the -host-header argument, like so:
./ngrok http -host-header=app.test 9283
you have to bind the ngrok server with the same port as rails server ./ngrok http 9283
You need "local-leg HTTPS."
./ngrok http https://app.test:9283

Unable to get the Response from angular7 services in production environment

I am new to angular and developed an angular application using angular CLI 7.
When I am running the application from my local system, I am getting the response from the service and it is working fine.
But when I deployed the application in the production server, I am unable to get the response from the service. Service is taking too long to respond and getting the HTTPErrorResponse of status Unknown Error.
We are using the Spring microservices for api calls to get the response data.
I am using the proxy.conf.json for the services because the URL running angular app is different from the service.
proxy.conf.json:
{
"/api/*":{
"target":"http://wsd185erd986.test.com/api",
"secure":false,
"loglevel":debug,
"changeOrigin":true
}
}
Changed the package.json to include the proxy.conf.json in proxyConfig.
Include the response headers in the service.
Could any one know on how to configure these proxy settings in production build for angular. Do we need to include any headers in the service calls.
HTTPErrorResponse - A response that represents an error or failure,
either from a non-successful HTTP status, an error while executing the
request, or some other failure which occurred during the parsing of
the response.
So as per the docs this error is thrown in multiple cases either there is an error at server end and server send the error response or there was some issue in parsing.
Please check the Spring Boot API request logs to see what response code is sent back.
You can check the API by a standalone client too (like Postman) and see if there is some issue.
As an aside - you should not be using angular development server in production as it is meant for angular development. Typically you can use any web server ( like Apache, NGinx etc) to host your angular production files ( they are merely static resources) and then either use them as a proxy ( by having their proxy configuration) or have CORS enabled services.

How does one develop a Shopify App in a local Rails environment?

I've been having some trouble trying to set up a Shopify app so that I can develop it in my local Rails environment.
I've followed the documentation HERE but when I install the app into my shopify dev store I get an error stating localhost sent an invalid response.
My local rails server log shows:
ERROR bad URI '::�+�/�,�0̨̩�\x14�\x13�\x13�\x14\x00�\x00�\x00/\x005\x00'.
ERROR bad Request-Line '\x16\x03\x01\x00�\x01\x00\x00�\x03\x03d��������\x1F�ŭ����=G�+q\r[��� N�\x00\x00 jj�+�/�,�0̨̩�\x14�\x13�\x13�\x14\x00�\x00�\x00/\x005\x00'.
After digging through other shopify docs I found this:
This says to tunnel with ngrok to avoid problems which makes sense, except that the shopify_app documentation states to specify http://localhost:3000 as the application URL and http://localhost:3000/auth/shopify/callback as the Redirection URL.
Can anyone tell me how to set my Shopify app so I can develop it locally? Or is this something I will have to develop live on heroku?
Ngrok is simply a tunnel to localhost, so you can set your application URL to https://subdomain.ngrok.io and redirection URL as https://subdomain.ngrok.io/auth/shopify/callback. You can configure ngrok to tunnel on port 3000 by specifying the port number when initializing ngrok: ./ngrok http 3000.

oauth: Meteor authentication issue on own server

I'm working on an app the requires a log-in by using oauth mechanisms from LinkedIn, Twitter, Google.
On the common meteor server this authentication method works fine.
However, I recently deployed the meteor server on my own server, and I get an authentication error when I try to log in. I tried linkedin and twitter and receive the same error, so I guess something is wrong on my server.
The error is in a browser window:
The requested URL /_oauth/linkedin was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.22 (Ubuntu) Server at exomodal.com Port 80
The meteor server is at port 3000.
Any ideas how to resolve this issue?
Thanks in advance
As far as I know, in Google, it asks for a redirect url and an origin url. During development, you registered these as localhost:3000/. But when you deploy, you are not using localhost anymore. Update these URLs in your "API console" (That's what they call it in Google) if any exists. As far as I know, Google and Facebook requires some sort of url registered.
Also, API configurations (client/consumer id and secret) are usually stored in the DB. Upon deploy, you don't usually ship your development DB, leaving behind the configurations which were on your development machine. What we did was to hard-code these into the server code, so that every time the server is restarted or redeployed to a "clean server", it inserts those configs to the DB.

Faye: Can't send GET messages in browser even though socket is open, working and responding with data via CURL

So my websocket is opening properly to faye, I'm using the nginx_tcp_proxy module. When I run a curl it looks good:
$ curl http://now.2u.fm:9200/faye\?message\=%5B%7B%22channel%22%3A%22%2Fmeta%2Fhandshake%22%2C%22version%22%3A%221.0%22%2C%22supportedConnectionTypes%22%3A%5B%22callback-polling%22%5D%2C%22id%22%3A%221%22%7D%5D\&jsonp\=__jsonp6__
__jsonp6__([{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"jls0srprht51xb368yrojft3h4drgu0","advice":{"reconnect":"retry","interval":0,"timeout":45000}}]);#
And curl with the -I flag
HTTP/1.1 200 OK
...
Connection: close
But I'm getting failed GET requests when my website tries to hit this as GET (no error code):
edit: I noticed it says "switching protocols" just now!
Same as when I try and hit the url directly in my browser.
My gut says, "hey, thats because you have a tcp connection open not an http one!", but then is private_pub using GET? But for all I know a GET request is just fine over TCP and I'm doing something wrong.
I found out the issue was that Faye needs to be able to open a socket and use http. Because private_pub assumes you do both on the same domain/port this was impossible using the tcp module without having to modify private_pub and the faye extension it was loading to use the right ports.
In the end I used HAProxy instead as it was much simpler to set up and required no modification of private pub.

Resources