Hosting an API
So I am new to making web apps and I was trying to make a website with express in backend. I didn't want to spend any money to host it so i tried vercel and after countless errors and asking for help in various server, it turns out u can't host your own api endpoints on your vercel app. So I took some advice from other people and they told me to keep the API on a different server. I remembered that my friend and I share a VPS so I hosted my API on it (Without any domain so i was making requests using the VPS' ip). It worked like a charm on my local machine but I guess vercel doesn't allow outgoing requests to urls without https (SSL certificates) and since my VPS doesnt have a certificate vercel kept requests to it.
I asked for help about this and someone told me to try cloudflare and they also mentioned pages and functions. I've never used cloudflare before so I have no idea what to do. Please help
26 Replies
help
What I would do is purchase a domain, and host your website from your VPS proxied through cloudflare.
Potentially using Cloudflare Tunnels, it is a fantastic product
hey so
im trying to use cf workers
to host my api there
also using wrangler
so like
can we make api calls in a worker ??
You can make calls to other APIs from a worker.
What are you trying to do here?
like so
but its logging undefined
also
call
isnt being logged
what u think the problem is ??then
is not async
You should do some research on async
in javascript. However... cloudflare workers don't use express, so...nah cuz
in my actual code
i need to do result.json() which returns a promise
im using hono
can you should your actual code?
Oop redact your API key!
yup sorry
Cloudflare will do a little bit of geolocation for you there, btw, in the request.cf object.
idk what that is its my 1st time