javahtmlangularserverangular-fullstack

Java Webserver W/ Angular Control Panel Web Interface


I have created an application using spring boot that uses angular for the front end and is a basic login portal with encrypted credentials and click verification, what I want to do is have like when someone visits the IP of the server it gets the angular portal, when it's a domain name, it actually pulls up that website. I want to program this to happen either in java or angular to request the resource from java. How would one go about implementing this? I know how to have java handle http requests and actually get the html to the browser... What I don't know is how to do that while using the angular front end to act as my control panel.

Here is my goal, user types in the Servers IP, which could be changed, "0.0.0.0" to the port that I specify which would be 8080 it brings them to my login page which is the angular front end. once they are authenticated it goes into the dashboard Control Panel to Manage the server, Ip's, etc. However if a user types in "Example.com", even if they type in port 8080 I want it to pull up the Index.hmtl File of "Example.com" not the Angular Cpanel. this would be an actual website with many pages and so on. the Angular portion is really just for server management changing files, updating Emails, and so on. Not sure this has ever been done before in the likes of java, I really just need to have the java App do one thing if its the IP and another if It's a Domain Name.

Update 03/24/22: Ok after further Research I am trying to achieve something like a Webmin, Plesk, cPanel esk type application. A user could make their website and such with the control panel which I was going to Use Angular combined with Spring boot. those applications will only bring up the login screen if you type in the IP and the specified port, else they are going to load the records and the sites that are required based on what the User has typed in, I don't know if this needs to be Angular passing a String to the Backend with a URL if the URL does not meet the criteria for the login screen to appear, or if there needs to be a different approach here.


Solution

  • Ok, so I have found the answer I am looking for is through a proxy, you can get the domain name from the answer in this solution. It seems that what I was looking for in this case is a proxy which is defined in Angular's Documentation here. Once you have these two put together, you can then pass the base URL or really the Entire URL Back to the Spring Boot backend to request the requested resource, however by using the proxy it seems this would not be needed and would just need the Backend to be able to handle requests as they are redirected to the Backend, which would then be passed back to the front end to put together for the client. building an httpserver is done by using this class and can be combined with some others to actually give the requests back to the angular application to then give back to the client.