Search code examples
reactjsjbossweb-deployment

Deploy react bundle on jboss eap 7.3?


I have a react project and I have created bundle using npm run build. And in package.json I have also defined the homepage attribute.

So when I try to deploy this bundle file folder on tomcat, the tomcat serves the static react content.

But JBOSS gives 404 error, that I am not able to understand why?

So if it will not work, then how to deploy react project on jboss server?


Solution

  • You need to define a location on where you want your bundle to 'live' and a handler to serve its content. With the jboss cli you need to execute the following commands :

    /subsystem=undertow/configuration=handler/file=react_handler:add(path="my_bundle_path")
    /subsystem=undertow/server=default-server/host=default-host/location=\/my_react_app:add(handler="react_handler")
    

    The first comment create an undertow handler to access the filesystem: https://docs.wildfly.org/24/wildscribe/subsystem/undertow/configuration/handler/file/index.html

    The 2nd command links this path to a resource location: https://docs.wildfly.org/24/wildscribe/subsystem/undertow/server/host/location/index.html