B4J Tutorial [abmaterial] How to remove the appname to access the web address?

Hanz

Member
hello,

abmaterial provides this: ipaddress:port/appname/

Is there a way to have this: ipaddress/

If you run your abmaterial application and you enter the ip address of the server, you need to specify the appname as shown above. Is there away to remove the appname so that you can directly get into the root?

At the Application.bas, there is comment that says uncomment the following code so that one can directly go to the root:

srvr.AddFilter( "/", "ABMRootFilter", False )

But, there is no difference when I did it. I still need to go through the appname.

Thanks.
 

alwaysbusy

Expert
Licensed User
What exactly does not work? I use it al the time. I mostly use it together with the ABMHttp2HttpsFilter Filter so http calls become https calls.

B4X:
srvr.AddFilter("/*", "ABMHttp2HttpsFilter", False )
e.g. when I type localhost in the url (I'm running a port 80, else you will have to add the port too), and it automatically goes to:

B4X:
https://localhost/duaal
duaal is my app name

the ABMRootFilter looks like this:

B4X:
'Return True to allow the request to proceed.
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
   resp.SendRedirect( "/" & ABMShared.AppName )  'AppName
   Return ( False )
End Sub
the ABMHttp2HttpsFilter looks like this:

B4X:
'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:") _
       .Replace(Main.srvr.Port, Main.srvr.SslPort))
       Return False
   End If
End Sub
On our VPS, where we have a registered domain name, the user types mydomain.com and ends up at:

B4X:
https://mydomain.com/duaal
If you do not want the 'duaal' part, you will have to do this outside of ABM on the VPS itself (probably some mask set in e.g. HAProxy but this is out of scope of ABM).
 

Hanz

Member
Thanks for the immediate response, I changed the port to 80 and no problem with that, my concern is what if you don't want your appname, in your example, "duaal" to appear on web address, just the "https://mydomain.com/"? And your answer is it is already outside of the ABM, but can you pls. provide further info on that or reference?
 
Last edited:

alwaysbusy

Expert
Licensed User
I'm not an expert on that (I never needed this), but I see in my https://www.dynu.com/ dashboard you can activate Mask url:



I kind of remember not using it for the demo because they use some <frame> trick and some components of ABM had some issues with that one mobile devices (can't recall which ones so you will have to test it with your app if it works).

You may want to start a new topic in the questions section of this forum on how to mask an url and maybe someone will be able to give you a tutorial on how to setup your VPS server to do that.
 

Hanz

Member
Again, thank you very much that will be useful info and congrats also, everybody knows your work is amazing...
 
Top