B4J Question Restrict access to jserver via https

tchart

Well-Known Member
Licensed User
Longtime User
You need to do this with a filter.

Before you start the server

B4X:
    'http to https redirect
    webserver.AddFilter("/*", "https_filter", False)

And the filter;

B4X:
'Filter class
Sub Class_Globals
   
End Sub

Public Sub Initialize
   
End Sub

'Return True to allow the request to proceed.
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
    If req.Secure Then
        Return True
    Else
        resp.SendRedirect(req.FullRequestURI.Replace("http:", "https:"))
        Return False
    End If
End Sub
 
Upvote 0
Top