GWT Front-end on different server than Back-end

100 views
Skip to first unread message

Bruno Borges

unread,
May 27, 2021, 1:56:06 AMMay 27
to GWT Users
Hey folks, Bruno Borges here from Microsoft. 

I've been reading the GWT documentation and trying to understand the deployment model of the front-end, especially for PWA apps (but not exlucisvely!) to find a scenario where GWT front-end could be deployed to Azure Static Web App service (to serve the static content), and then the back-end APIs deployed as an Azure Function. 

 I wonder if anyone has played with the general idea of deploying front-end on a different server (Nginx/Apache) only to serve the static content, and the actual API back-end to another.

Peter Donald

unread,
May 27, 2021, 3:59:30 AMMay 27
to GWT Mailing List
Hi,

On Thu, May 27, 2021 at 3:56 PM Bruno Borges <bruno....@gmail.com> wrote:
I've been reading the GWT documentation and trying to understand the deployment model of the front-end, especially for PWA apps (but not exlucisvely!) to find a scenario where GWT front-end could be deployed to Azure Static Web App service (to serve the static content), and then the back-end APIs deployed as an Azure Function. 

 I wonder if anyone has played with the general idea of deploying front-end on a different server (Nginx/Apache) only to serve the static content, and the actual API back-end to another.

This is the way we deploy most of our applications and it is not really any different from how you have to do it for any other javascript context and the standard security concerns. The only tricky part really is working with your transport layer. If you are using GWT-RPC (which I recommend against) then you are stuck updating the server and the client at the same time if you ever change the API in a backward incompatible manner and you have to do some ugly configuration of base url of services. Assuming the Azure Function can be accessed as http calls then you should be fine.

If you are using the "builtin" support for separating our resources (i.e. GWT.getHostPageBaseURL(), GWT.getModuleBaseForStaticFiles(), GWT.getModuleBaseURL()) for accessing assets then you may find some things break for local development when GWT.getModuleBaseForStaticFiles() != GWT.getModuleBaseURL() as GWT.getModuleBaseForStaticFiles() does not take into account the debug hooks but this is pretty rare scenario.

Is there a specific problem that you are having?

--
Cheers,

Peter Donald

lofid...@gmail.com

unread,
May 27, 2021, 9:18:24 AMMay 27
to GWT Users
Hi Bruno,

Yes, it is actually the standard way to deploy GWT webapp (at the end you transpile Java to JavaScript: it is JavaScript + HTML + resources) in just a simple web server (NginX or Apache).

The web app communicates with the server side by using GWT-RPC (like what Peter said above) or many of us are using REST on the backend (Spring Boot ...).

Of course you can also just deploy the JS + HTML + resources in Spring Boot "static" directory if you don't want to make an extra web server.

If you have any special idea with Azure, just tell me, I could try to make a simple example ;-)

Question: Can we access AzureFunction with REST API? Or how do you access AzureFunction?

Greets,
Lofi

lofid...@gmail.com

unread,
Jun 4, 2021, 12:36:57 PMJun 4
to GWT Users
@Bruno: 

I tried to deploy a simple GWT webapp to Azure Static Web App service. Here is my simple example:

https://github.com/lofidewanto/gwt-azure-static-webapp

My problem is that it won't run Maven to build the JS files. Here is my github actions for Azure Static Web App:


I'm not sure how can I build with Maven to transpile to the JS files so that I could serve from this directory:

/target/gwt-azure-static-webapp-1.0.0-SNAPSHOT/calculator

Thanks, Lofi

lofid...@gmail.com

unread,
Jun 4, 2021, 3:41:21 PMJun 4
to GWT Users

lofid...@gmail.com

unread,
Jun 5, 2021, 5:31:25 PMJun 5
to GWT Users
Hi All,

I wrote a short article "Deploy GWT / J2CL Web Apps on Azure Static Web Apps Service"


Enjoy!
Lofi
Reply all
Reply to author
Forward
0 new messages