Base solution for your next web application
Open Closed

How can i config angular app to use API in other server #5423


User avatar
0
kwanp created

Hi I just publish asp.net core API to IIS Server and i want my programmer to use this service to testing and development angular app for design layout on clients side It is possible and how can set this setting

Thank you

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    You can set it here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/assets/appconfig.json#L2">https://github.com/aspnetzero/aspnet-ze ... ig.json#L2</a>

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    kwanp created

    <cite>ismcagdas: </cite> You can set it here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/assets/appconfig.json#L2">https://github.com/aspnetzero/aspnet-ze ... ig.json#L2</a>

    Hi i still cannot get my angular app to work after i change aspnet-zero-core/angular/src/assets/appconfig.json

    {
      "remoteServiceBaseUrl": "http://192.168.100.99:2500",
      "appBaseUrl": "http://localhost:4200",
      "localeMappings": [
        {
          "from": "pt-BR",
          "to": "pt"
        },
        {
          "from": "zh-CN",
          "to": "zh"
        },
       {
          "from": "he-IL",
          "to": "he"
       }
      ]
    }
    

    after i open chrome browser to test on development time the error show this

    Failed to load <a class="postlink" href="http://192.168.100.99:2500/AbpUserConfiguration/GetAll">http://192.168.100.99:2500/AbpUserConfiguration/GetAll</a>: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

    how can i solve with this issue Thank you

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Check Logs.txt file of the app running on <a class="postlink" href="http://192.168.100.99:2500">http://192.168.100.99:2500</a> to see if there are any error messages.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    kwanp created

    <cite>ismcagdas: </cite> Check Logs.txt file of the app running on <a class="postlink" href="http://192.168.100.99:2500">http://192.168.100.99:2500</a> to see if there are any error messages.

    Hi i already see the error on Logs.txt

    INFO 2018-07-30 10:16:22,121 [8 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://192.168.100.99:2500/AbpUserConfiguration/GetAll">http://192.168.100.99:2500/AbpUserConfiguration/GetAll</a>
    INFO 2018-07-30 10:16:22,121 [8 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution failed. INFO 2018-07-30 10:16:22,121 [8 ] pNetCore.Cors.Infrastructure.CorsService - Request origin <a class="postlink" href="http://localhost:4200">http://localhost:4200</a> does not have permission to access the resource. INFO 2018-07-30 10:16:22,121 [8 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 0.373ms 204 INFO 2018-07-30 10:17:06,191 [8 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://192.168.100.99:2500/AbpUserConfiguration/GetAll">http://192.168.100.99:2500/AbpUserConfiguration/GetAll</a>
    INFO 2018-07-30 10:17:06,191 [8 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution failed. INFO 2018-07-30 10:17:06,191 [8 ] pNetCore.Cors.Infrastructure.CorsService - Request origin <a class="postlink" href="http://192.168.100.108:4200">http://192.168.100.108:4200</a> does not have permission to access the resource. INFO 2018-07-30 10:17:06,191 [8 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 0.3659ms 204

    how can i config to allow this client on development time to access and use this api service

    Thank you

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    kwanp created

    Hi i just solve this issue by adding my clients ip address that can access to appsettings.production.json on my API site

    "CorsOrigins": "http://localhost:4200, <a class="postlink" href="http://192.168.100.108:4200">http://192.168.100.108:4200</a>"

    Thank you

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    alper created
    Support Team

    thanks for your feedback

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)