I'm trying to integrate Plaid transaction webhooks into an api, and seem to have trouble getting any webhooks to fire. I used the plaid quickstart code and added the webhook parameter:
Plaid.create({
apiVersion: "v2",
clientName: "Plaid Walkthrough Demo",
env: "<%= PLAID_ENV %>",
product: ["transactions", "auth"],
webhook: "http://localhost:3000/api/plaid/webhook",
key: "<%= PLAID_PUBLIC_KEY %>",//...
On the receiving end I'm just logging the req.body to see if webhook fired:
app.post("/api/plaid/webhook", (req, res) => {
console.log("WEBHOOK FIRED");
console.log(JSON.stringify(req.body));
});
When I tested the route in Postman, the req.body was logged as expected, but when creating a new PLAID Item it's not working. I'm currently working in Sandbox mode
Wrote to Plaid support and the reason it didn't work is because localhost:3000 is not a valid URL. Once i tried it on an actual server it worked.
As you already found out yourself, localhost:3000 won't work since it's not public (visible to Plaid).
When I want to test webhooks locally, I typically user services like:
https://postb.in
https://webhook.site
Like Plaid support mentioned, localhost:8000 isn't a public URL so Plaid can't see it.
However, its easy to give localhost a public URL using expose.sh. Then you can test the webhook locally.
Install expose.sh
For Mac or Linux, go to Expose.sh and copy/paste the installation code shown into a terminal.
For Windows go to Expose.sh, download the binary and put it somewhere in your PATH.
Expose your api to the web
Start your API server. Then run expose <port> where port is the port your API server is running on, like 80 or 8080.
Expose.sh will generate a random public expose.sh URL. You'll see output like
https://s3rh.expose.sh is forwarding to localhost:80
http://s3rh.expose.sh is forwarding to localhost:80
Then you can get Plaid to use the public HTTPS URL, which will forward to localhost.
I've written a full guide here
Disclaimer: I built expose.sh
Related
I put my frontend application in the public folder for a node.js application and am getting the form-data using the following request:
try {
await axios.post("/api/v1/contact-form", {
name,
email,
msg,
});
}
My backend is in port 5000 and it's handling the request by:
app.use("/api/v1/contact-form", submitFormRouter);
It works perfect. I'm getting the data when I have my frontend application is in the node.js public folder.
My question is if my frontend is running on a different local port such as, if I use "Five server" to run the frontend application, how do I replace the following path for post:
Frontend:
try {
await axios.post("/api/v1/contact-form", {
name,
email,
msg,
});
}
Backend:
app.use("/api/v1/contact-form", submitFormRouter)
I've also tried the code using React in which case the frontend is running in http://localhost:3000/ and node.js server running in 5000, the code still works and I'm getting the form data. But, how do I make it work for a frontend application sitting in a different port(without react)?
Additionally, I hope you're kind enough to answer the following question- What would be the path once I have the frontend let's say on Netlify whereas the backend is on Heroku?
What would be the path once I have the frontend let's say on Netlify whereas the backend is on Heroku?
Let's assume your Back on Heroku has this url https://app.herokuapp.com/ and the Front on Netlify this one https://app.netlify.com/. All you have to do is to give your Front your Back's url, like so:
try {
await axios.post("https://app.herokuapp.com/api/v1/contact-form", {
name,
email,
msg,
});
}
My question is if my frontend is running on a different local port such as, if I use "Five server" to run the frontend application, how do I...
At this point you have two choices, the simplest one is to use a complete url like above. Let's assume your Front is on port 3000 and the Back on 8080. All you have to do again is:
try {
await axios.post("http://localhost:8080/api/v1/contact-form", {
name,
email,
msg,
});
}
The second one is to use a proxy, and this really depends on your projects' structure and need.
I would like to publish this project private server I have -
https://github.com/Autodesk-Forge/bim360appstore-model.derivative-nodejs-xls.exporter
The above project has been deployed on Heroku, with the following Callback URL & redirect_uri.
I am using a private server https://172.xx.xxx.xx instead of Heroku so could you tell me how to deploy the application on the private server. And what should be the callback URL and redirect_uri for the same?
Please find the screenshot where I want to deploy the application where It mentioned the webroot -https://ibb.co/Kqf6tVd
Both callback URL and redirect_uri are the same things. You need to replace http://localhost:3000 with your private server base url.
//From
http://localhost:3000/api/forge/callback/oauth
//To
https://172.xx.xxx.xx /api/forge/callback/oauth
https://github.com/Autodesk-Forge/bim360appstore-model.derivative-nodejs-xls.exporter/blob/master/server/config.js#L26
I have set up a prerender server on my local machine.
It is on port 3033 and it seems to display a rendered version of my meteor site when I type this in
curl http://localhost:3033/http://localhost:3000/?_escaped_fragment_=
Knowing that my prerender site works, I'm trying to set it up so that if I go to
curl http://localhost:3000/?_escaped_fragment_=
it should give me my Meteor site.
I'm using this package (https://github.com/dfischer/meteor-prerenderio) and I've got this line in my settings.json file
"PrerenderIO": {
"prerenderServiceUrl": "http://localhost:3033/"
}
However, when I run
curl http://localhost:3000/?_escaped_fragment_=
it returns nothing and I'm getting this message shown up on my meteor server log
res.send(status, body): Use res.status(status).send(body) instead
and it doesn't seem to be hitting the prerender server.
What is this message and why aren't I able to hit the prerender server?
I've setup a webhook for a repository on Github. When I create a new release in Github, my webhook receiver (on a Node server) receives a request. It works like this (using Express):
app.post("/", function(req, res){
//request is not a github event
if (req.headers["x-github-event"] != "release") return;
//request is a pre-release
else if (req.body.release.prerelease) deployToDev();
//request is full release
else if (!req.body.release.prerelease) deployToLive();
});
As you can see, it first checks if the request includes a header of a github event with a value of release. If that's all good, it checks whether it's a prerelease or a full release and fires a function to either deploy to dev or live.
The webhook works great, but I'm struggling to find out how to actually deploy the files. Do I do this with some kind of FTP connection or shell script? The dev and live directories are on the same server as the webhook receiver. What is the best way to do this?
If you're already using github, a simple way to deploy is by checking out the code on the target machine.
A trade off is that the target machine needs to have git installed and have credentials to read from your repository.
Another option is to do what you suggested in your question: download archive using your node program above and transferring it to the machine you are deploying on using your protocol of choice: FTP/ssh/rsync/scp, etc..
This must be an extremely common problem. I've seen various answers for this but none seem to work for me.
I have node installed on an apache server on Windows Azure. My app is built and ready to go (snippet below):
var express = require("express");
var app = express();
//example api call
app.get("/api/example", function(req, res){
//do some process
res.send(data);
});
app.listen(8080);
console.log("App listening on port 8080");
Now, when testing on my own computer, I could then go to localhost:8080, which works great. But now I've put it on the azure server I can't get an external domain to point to it properly. So for example, I have the domain:
framework.example.com
I've added this to my hosts file in Azure:
XXX.0.0.01 framework.example.com
Initially I tried also editing the http-vhosts.conf to point the domain to the correct directory. This worked for loading the frontend, but the app couldn't talk to the backend. API calls returned 400 not found errors.
I've also tried an Express vhost method but think I'm doing it wrong and don't fully understand it. What is the correct method?!
My app structure is like this:
- package.json
- server.js
- server
- files used by server.js
- public
- all frontend files
So to boot the server I run server.js which runs the code at the top. The server.js uses the below Express config to point to the public folder.
app.use(express.static(__dirname + "/public"));
Adding it to the hosts file in Azure won't help. You'll need to configure your domain's DNS to point to Azure. I'd recommend using the DNS Name of your Cloud Service instance. Your underlying VM IP address could change if you need to stop it for some reason, but your Cloud Service DNS name is configured to always route to your underlying VMs. That means you'll need to setup a CNAME with your DNS.
Read more about that here: Cloud Services Custom Domain Name
Next, you'll either need to host the node app on port 80, or put a proxy in front of it to handle that for you. Otherwise you'll be stuck typing framework.example.com:8080 which is not ideal. On linux, you'll likely need to be a privileged user to host on port 80, but you never want your node app to have root privileges. You can use authbind to work around this problem.
See an example of how to use it with node here: Using authbind with Node.js
All that being said, it seems like you're somewhat new with linux server management. If that's the case, I'd strongly recommend trying to use something like Azure Websites instead of a VM. You no longer have to manage the virtual machine OS. You simply tell it to host your application and it takes care of the rest. If you're using github, this is incredibly easy to test and iterate with. It does host on Windows under the hood, and that might problems for some applications, but I host all my node sites there (developed on Mac) without any issues.