akveo / ngx-admin-bundle-support

Support repository for ngx-admin backend bundles with issues tracking, instructions and code samples
58 stars 32 forks source link

CORS - SSL Issues and Implementation #85

Open enixlabs opened 3 years ago

enixlabs commented 3 years ago

Good evening.

We are currently trying to setup everything so that the backend and frontend are not on the same network and so processes the request over HTTPS, however we are having issues trying to implement SSL on the backend.

site: https://enixlabs.uk api: https://enua.me <---- Https isn't working

We've tried various options.

const https = require('https') <-- Added code for https
const fs = require('fs') <-- Added certs

polyfills-es2015.8df41bc2e30885896a47.js:1 Mixed Content: The page at 'https://enixlabs.uk/auth/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://enua.me:3001/api/auth/login'. This request has been blocked; the content must be served over HTTPS.

polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://[PUBLICIP]:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://enua.me:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR

Are we missing something when it comes to adding SSL, as nothing seems to work.

We also had to update the app.js for CORS

app.all('/', (req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'X-Requested-With');
  next();
});

As it wasn't passing the CORS request for authentication, fixed that problem with the above...

enixlabs commented 3 years ago

image

This was the issue with CORS before adding in the ACA

enixlabs commented 3 years ago

I've noticed by taking out the port, the CORS issue presents itself again.

tmnunes commented 3 years ago

Good evening.

We are currently trying to setup everything so that the backend and frontend are not on the same network and so processes the request over HTTPS, however we are having issues trying to implement SSL on the backend.

site: https://enixlabs.uk api: https://enua.me <---- Https isn't working

We've tried various options.

const https = require('https') <-- Added code for https
const fs = require('fs') <-- Added certs

polyfills-es2015.8df41bc2e30885896a47.js:1 Mixed Content: The page at 'https://enixlabs.uk/auth/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://enua.me:3001/api/auth/login'. This request has been blocked; the content must be served over HTTPS.

polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://[PUBLICIP]:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://enua.me:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR

Are we missing something when it comes to adding SSL, as nothing seems to work.

We also had to update the app.js for CORS

app.all('/', (req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'X-Requested-With');
  next();
});

As it wasn't passing the CORS request for authentication, fixed that problem with the above...

Did you solve the issue? how?

Thanks

enixlabs commented 3 years ago

Good evening. We are currently trying to setup everything so that the backend and frontend are not on the same network and so processes the request over HTTPS, however we are having issues trying to implement SSL on the backend. site: https://enixlabs.uk api: https://enua.me <---- Https isn't working We've tried various options.

const https = require('https') <-- Added code for https
const fs = require('fs') <-- Added certs

polyfills-es2015.8df41bc2e30885896a47.js:1 Mixed Content: The page at 'https://enixlabs.uk/auth/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://enua.me:3001/api/auth/login'. This request has been blocked; the content must be served over HTTPS. polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://[PUBLICIP]:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR polyfills-es2015.8df41bc2e30885896a47.js:1 POST https://enua.me:3001/api/auth/login net::ERR_SSL_PROTOCOL_ERROR Are we missing something when it comes to adding SSL, as nothing seems to work. We also had to update the app.js for CORS

app.all('/', (req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'X-Requested-With');
  next();
});

As it wasn't passing the CORS request for authentication, fixed that problem with the above...

Did you solve the issue? how?

Thanks

Yes in a fashion, we implemented docker into the system and used Nginx to proxy the connection, which gave us full SSL between the two.