function demo(request,response){
request.getScheme() is returning http instead of returning https.
System.out.println(\"\"+request.getScheme());
}
If your server is running behind a proxy server, make sure your proxy header is set:
proxy_set_header X-Forwarded-Proto $scheme;
Then to get the right scheme
you can use springframework's classes:
HttpRequest httpRequest = new ServletServerHttpRequest(request); //request is HttpServletRequest
UriComponents uriComponents = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
String scheme = uriComponents.getScheme(); // http/https