0

This is a testing application i'm doing.

https://cfslpro.com/student_portal/

username : chanu

password : 123456

Before adding HTTPS , this login and everything worked. But now nothing is working. I tried adding following solutions to my NodeJS server.

This is how I configured my server.js file :

var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);

httpServer.listen(8080);
httpsServer.listen(7000);

I have both HTTP and HTTPS ports opening. When I open this link "https://165.227.121.28:7000/api/user_manage/login" in my browser, it's saying connection is not secure. And also there's a CORS error coming when I'm trying to access above mentioned URL with username and password. My domain is protected with HTTPS. Can I bypass to HTTPS and use my REST API in http ? This configuration kills me. Or do we need to create a fully HTTPS enabled REST API using Node.JS ?

This is the error i'm facing. When trying to login, I'm getting this error :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://165.227.121.28:7000/api/user_manage/login. (Reason: CORS request did not succeed).

do I need to use a proxy server for this ? what is the simplest solution to fix this ?

  • What is "not working"? How does it fail? What is the error? Why are you running an API server on an IP address without a domain name? – Michael Hampton Dec 14 '18 at 14:20
  • @MichaelHampton please check the question.. i added an error response. – Chanaka De Silva Dec 14 '18 at 14:25
  • Yes, you need to proxy NodeJS through Apache so that it is served on your domain name. – Michael Hampton Dec 14 '18 at 14:28
  • @MichaelHampton I'm really new to this field. Can you please give me some examples, At least tell me how to solve and add a proxy server ? I got this tutorial , but it's not clear :-( https://sawtooth.hyperledger.org/docs/core/releases/1.0/sysadmin_guide/rest_auth_proxy.html – Chanaka De Silva Dec 14 '18 at 14:30
  • There are [many tutorials](https://www.google.com/search?q=how+to+run+nodejs+with+apache) out on the Internet. You aren't limited to one. – Michael Hampton Dec 14 '18 at 14:34
  • @MichaelHampton thanks for your information buddy . If you can, please reccomond me one good solution. A simple one to follow please. Sorry if i'm disturbing you. Tried many solutions online, still no good. – Chanaka De Silva Dec 14 '18 at 14:36
  • I can't recommend a solution using apache; I use nginx :) – Michael Hampton Dec 14 '18 at 14:37
  • Thank you so much @MichaelHampton for the support. I will try more.. – Chanaka De Silva Dec 14 '18 at 14:39
  • the issue is that you creating both http & https server. try to remove the http and let only https server run – Tirolel Dec 14 '18 at 14:44
  • @Tirolel i did that. Still not working -( app.listen(config.port, function (err) { if (err) { console.log(err); } else { console.log("localhost:7000"); } }); – Chanaka De Silva Dec 15 '18 at 07:35

0 Answers0