Search code examples
angularspring-bootdeploymentweb-applications

How to deploy spring/angular web application locally accessible on local network


I am confused about deploying my webapp on a local server that has to be accessible by devices on local network.

I've created a DB, a spring boot backend and an angular frontend. I built them and have my WAR and dist files ready to be deployed. Let's say I have XAMPP installed on my PC, how can I deploy my webapp and DB on it and how do I make it accessible from all devices on the local network?

Thanks for your help


Solution

  • You can also use nginx. It can be a little simpler for your case.

    Q: How can I deploy my webapp in xampp?
    A: go to /dist in angular. if js & html source files were not there then navigate to the folder containing them (if you are using angular universal and there was a /server directory, you should be running it on node man!)

    Q: How can I deploy my DB on xampp?
    A: You don't need to :|

    Q: How do I make it accessible to all devices from the same network?
    A: first find your own machine ip where back end is running, then assign the api_url in endpoints of your endpoints in api.service.ts in angular or where ever you are calling httpClient methods.

    And that's it.


    You see, every time a device which is connected to your hotspot (the hotspot of the machin which runs the backend or generally a network which that back end serving on) sends a request to your ip on what ever port (I think xampp is on 80 by default so you dont need to set any port in the url!) your xampp is on, it will get a copy of the angular build which connects to your back end server ip and thus does the interactions. if you interact with database in spring boot, then that part is done locally.