Search code examples
angularbeego

Beego and Angular 4


I'm trying to get my head around using beego and Angular4 together. I'm trying to use the angular-cli and generate a new project. Has somebody used the two frameworks together and can share a few insights on setting up their development and production setup/settings etc.

Thank you


Solution

  • this question might be a bit old. buit it can be useful to someone else.

    Use your Angular 4 as Front end alone, and let your Beego app to act like an api. create an angular 4 app somewhere in your dev's folders. and create an go app inside your source folder. I have same set up as you trying to do.

    and if you want them to act as in the same domain name. you can refer into this nginx server block.

    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;
    }