angularjs - Insecure Reponse on https access with ExpressJS/NodeJS -
i keep having recurring issue on custom site built on wamp.
i followed instructions on how generate self-signed certificate , private key ssl. use, nodejs/expressjs create https server use web api data on site. employing angularjs display data.
now confusing part sometimes, works on google chrome. however, fails on firefox, opera , microsoft edge.
on angularjs file have this:
testcontrollers.controller('summoner-by-name', ['$scope', '$http', '$resource', function($scope, $http, $resource) { $scope.summonername = {text: 'abc'}; $scope.items = regions; $scope.submit = function () { settimeout(function() { data = {"summonername": $scope.summonername.text, "region": $scope.items.selectedoption.name, "pid": "000"}; $http({ method: 'post', url: 'https://localhost:3030/custom_project', datatype: "json", headers: { "content-type": "application/json", "content-length": data.length }, data: data }).then(function(response) { $scope.posts = response.data; }); }, 1000); } }]); ...
on node js file, have this:
app.use(function (req, res, next) { res.setheader('access-control-allow-origin', 'https://custom_site.com'); res.setheader('access-control-allow-methods', 'get, post, options, put, patch, delete'); res.setheader('access-control-allow-headers', 'x-requested-with,content-type'); res.setheader('access-control-allow-credentials', true); next(); }); var options = { key: fs.readfilesync('c:/wamp/www/custom_project/ssl_certs/private.key'), cert: fs.readfilesync('c:/wamp/www/custom_project/ssl_certs/public.crt'), ca: fs.readfilesync('c:/wamp/bin/php/php5.5.12/cacert.pem'), }; app.post('/custom_project', function (req, res) { ... } https.createserver(options, app).listen(3030);
the following messages receive on console when trying retrieve data nodejs/expressjs server:
microsoft edge:
script7002: xmlhttprequest: network error 0x80070005, access denied.
firefox:
cross-origin request blocked: same origin policy disallows reading remote resource @ https://localhost:3030/custom_project. (reason: cors request failed).
opera (and on chrome):
options https://localhost:3030/custom_project net::err_insecure_response
i'm under assumption because of certificate being self-signed wrong. ideas?
i found workaround issues had.
for firefox , opera, tracked errors on network tab on developers tool. request not going through node js script because of certificate issue. so, using these browsers, navigated https://localhost:3030/custom_project.
a prompt informed me site not trusted , navigate it, had add trusted sites list. after doing that, ran ajax post call , showed me results.
edge, however, has not given me luck. has error on top left corner saying site not trusted , couldn't same firefox, opera , chrome.
Comments
Post a Comment