使用暗潮服务AngularJS [英] Use Undertow to serve AngularJS

查看:166
本文介绍了使用暗潮服务AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用暗潮作为一个简单的Web服务器提供一个AngularJS应用。由AngularJS应用程序所需的其他服务是由Apache的骆驼服,所以我只需要使用暗潮服务于角应用。

我已阅读文档,但无法得到它的工作,什么我做错了任何想法?

下面是code,我现在已经启动Underow服务器

 暗潮服务器= Undertow.builder()
            .addHttpListener(8080,本地主机)
            .setHandler(资源(新为FileResourceManager(新文件(../ DIST),10))
                    .addWelcomeFiles(../ DIST / index.html的)
                    .setDirectoryListingEnabled(真))
            。建立();
    server.start();


解决方案

文件(../ DIST)的问题。使用绝对路径或至少一个无..,那么它​​应该工作。

(暗潮包含一个全面的检查比较计算的文件路径,其规范的路径,打破上的资源。和..。)

I would like to use Undertow as a simple web server for serving an AngularJS application. The rest services needed by the AngularJS application is served by Apache Camel so I would only need to serve the Angular App using Undertow.

I have read the documentation but cannot get it working, any ideas on what I am doing wrong?

Here is the code that I have now for starting 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();

解决方案

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

(Undertow contains a sanity check comparing the computed file path for a resource with its canonical path, which breaks on "." and "..".)

这篇关于使用暗潮服务AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆