Beego和Angular 4

时间:2017-07-26 18:30:11

标签: angular beego

我试图一起使用beego和Angular4。我试图使用angular-cli并生成一个新项目。是否有人将这两个框架结合使用,可以就设置开发和生产设置/设置等方面分享一些见解。

谢谢

1 个答案:

答案 0 :(得分:2)

这个问题可能有点旧。 buit它对其他人有用。

单独使用Angular 4作为前端,让你的Beego应用程序像api一样行动。 在dev的文件夹中的某个位置创建一个角度4应用程序。并在源文件夹中创建一个go应​​用程序。我有同样的设置,你想做。

如果您希望它们在同一域名中运行。你可以参考这个nginx服务器块。

server {
    listen 80;
    server_name example.com;
    add_header 'Access-Control-Allow-Origin' '*';
    ## This is your Angular 4 app
    location / {
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_pass http://127.0.0.1:4200/;
    }
    ## This is your beego app
    location /api/ {
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_pass http://127.0.0.1:9999/;
    }

    access_log  /some/folder/example.com.access.log;
    error_log  /some/folder/example.com.error.log;
}