I have developed a Node.js REST API. When I upload it to cloud server then the API is accessible by HTTP but not by HTTPS. When sending requests to my website the API shows an error called (failed). I use Apache on my server. So now what can I do now for making live this API?
Related
I am fetching an API via JavaScript on my localhost. This leads to me having the CORS error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Will this still occur when my site is hosted on a my web server, or is it just an issue when I'm hosting via localhost?
If the request is to an external API (not your own site), then the error will continue to occur if the request is made from the client-side.
If the request is to an API on your own site, the error will no longer be present, because browsers allow you to make direct requests to endpoints on the same domain without restrictions.
Even if the API isn't your own, hosting your site on a server can help with these issues because you'll have the option of having your server relay the request to the external API. Clients can't make a request to the external API directly, but they can make a request to an endpoint on your site - and you can set up an endpoint to then make a request to the external API, and relay the response back to the client.
So instead of
client -> external API -> client (doesn't work)
having a server allows you to
client -> your server -> external API -> your server -> client (works)
I have implemented a resteasy service runs on Wildfly server, which communicates with a mysql database. The frontend runs on an apache server and sends xhr requests to the rest service via javascript. Through port mapping I was able to call the javascript frontend in remote, but not to call the backend. Any solution?
I have frontend written in angular and backend written in Spring. I bought hosting and there I installed tomcat where im deploying my production backend. Im deploying frontend under domain folder on my hosting service.
Spring has jks certificate. I added this jks certificate to connectors in server.xml.
Angular has let's encrypt certificate which was generated for my domain "spotmapa.pl".
Now i have this situation:
On desktop google chrome my domain seems "not secure" and when this website makes api calls for backend it does it correct.
But in for example firefox my domain seems secure and has padlock but api calls to backend not working from there.
My api calls to backend from postman works properly, but doesnt work from secured by lets encrypt website.
I dont get any errros in logs.
I have two questions:
Should i have the same certificate for backend and frontend?
Why does unsecured origins make api calls right, but secured website https://spotmapa.pl no?
Frontend with lets encrypt was calling api secured by selfsigned certificate. This caused problem. I did lets encrypt for the backend too and it works correctly.
I'm currently making a webpage that will show the status of the endpoints of my api. I have little background in nodejs. The webpage is simply a table that has the endpoint name and shows red/green/yellow box. I had some problems using ajax because of the cross-origin header. I was using the XMLHttpRequest.
Now I will try to do is creating a nodejs server that can fetch this information but I'm having some problems understanding if I need to use express in order to create an app or can I use the 'request' library.
Im kinda confused on how to connect my frontend with a nodejs backend.
Typically you connect your front end to a nodejs background the way you connect most client apps to an api, through an Ajax request (XMLHTTPRequest). If you want real-realtime then you would use sockets so you can push updates to the page. If slightly realtime is ok, then you can poll from the client every 5-10 seconds.
You mentioned CORS. If you are trying to access an API that doesn't set cross-origin header, then you proxy requests through your express server since CORS is a browser policy.
Without more information I can't be more specific.
I am developing an cross platform html5 javascript application. In that I have to fetch data from secure ssl enable web api. I am getting problem while calling this web api from server by sending response "access forbidden" when I disable the SSL on server it works fine. So to resolve this I have to add client certificate while requesting/communicating with these API's. I have used both jquery.ajax and xmlhttmRequest to fetch data from server in Javascript but it gives error for web api where SSL implemented. Please let me know to resolve this. Thanks.