Use Undertow to Serve AngularJS

I would like to use Undertow as a simple web server to serve the AngularJS application. The rest of the services needed for the AngularJS application are served by Apache Camel, so I will need to serve the Angular application using Undertow.

I read the documentation but can't get it working, any ideas on what I'm doing wrong?

Here is the code I have to start the Underow server

Undertow server = Undertow.builder()
            .addHttpListener(8080, "localhost")
            .setHandler(resource(new FileResourceManager(new File("../dist"),10))
                    .addWelcomeFiles("../dist/index.html")
                    .setDirectoryListingEnabled(true))
            .build();
    server.start();
+4
source share
2 answers

File("../dist")- a problem. Use an absolute path, or at least one without "..", then it should work.

(Undertow , , "." "..".)

+2

ClassPathResourceManager.

ResourceManager rm = new ClassPathResourceManager(getClass().getClassLoader(), "dist");
ResourceHandler handler = new ResourceHandler(rm);
0

Source: https://habr.com/ru/post/1548330/


All Articles