Open Closed

Running angular localhost with production instance of ABP #3010


User avatar
0
learnabp created
  • ABP Framework version: v5.1.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

Guys I am trying to run the angular project locally with a production ABP instance which is live and it gives me a cors error …. My cors setting in my appsetting.json includes Localhost … when in production does ABP not accept connections from Localhost ?

looking at the logs my production website says

2022-04-30 12:46:42.118 +00:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 566.6566ms
2022-04-30 12:46:42.118 +00:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2022-04-30 12:46:42.118 +00:00 [INF] Request finished HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/api/abp/application-configuration - - - 200 - application/json;+charset=utf-8 626.0485ms
2022-04-30 12:46:42.371 +00:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
2022-04-30 12:46:42.390 +00:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 397.8441ms
2022-04-30 12:46:42.390 +00:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2022-04-30 12:46:42.390 +00:00 [INF] Request finished HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/api/abp/application-configuration - - - 200 - application/json;+charset=utf-8 456.3726ms
2022-04-30 12:46:56.404 +00:00 [INF] Request starting HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/.well-known/openid-configuration - -
2022-04-30 12:46:56.404 +00:00 [INF] CORS policy execution successful.
2022-04-30 12:46:56.453 +00:00 [WRN] Origin is not allowed: http://localhost:8100
2022-04-30 12:46:56.453 +00:00 [WRN] CorsPolicyService did not allow origin: http://localhost:8100
2022-04-30 12:46:56.453 +00:00 [INF] No CORS policy found for the specified request.
2022-04-30 12:46:56.483 +00:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryEndpoint for /.well-known/openid-configuration
2022-04-30 12:46:56.501 +00:00 [INF] Request finished HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/.well-known/openid-configuration - - - 200 - application/json;+charset=UTF-8 97.3644ms
2022-04-30 12:46:56.523 +00:00 [INF] Request starting HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/api/abp/application-configuration - -
2022-04-30 12:46:56.524 +00:00 [INF] CORS policy execution successful.
2022-04-30 12:46:56.570 +00:00 [INF] No CORS policy found for the specified request.
2022-04-30 12:46:56.581 +00:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
2022-04-30 12:46:56.581 +00:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync() on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).

or appsettings.json is as follows

{ "App": { "SelfUrl": "https://dfo-dev-web.azurewebsites.net", "ClientUrl": "https://dfo-dev-word.azurewebsites.net", "CorsOrigins": "https://*.dfo-dev-web.azurewebsites.net,https://dfo-dev-word.azurewebsites.net,https://dfo-dev-web.azurewebsites.net,https://dfo-dev-public.azurewebsites.net,http://localhost:4200,http://localhost:8100", "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307,http://localhost:8100" }, .....


4 Answer(s)
  • User Avatar
    0
    learnabp created

    These are the errors I am getting in the console

    here is the log in debug mode

    2022-05-02 10:42:51.038 +00:00 [DBG] Added bundle 'Lepton.Global' to the page in 8.59 ms.
    2022-05-02 10:42:51.039 +00:00 [INF] Executed page /Index in 762.1019ms
    2022-05-02 10:42:51.039 +00:00 [INF] Executed endpoint '/Index'
    2022-05-02 10:42:51.040 +00:00 [INF] Request finished HTTP/1.1 GET http://staging.ppm.desertfireonline.com/ - - - 200 - text/html;+charset=utf-8 851.3424ms
    2022-05-02 10:42:59.894 +00:00 [INF] Request starting HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/.well-known/openid-configuration - -
    2022-05-02 10:42:59.916 +00:00 [INF] CORS policy execution successful.
    2022-05-02 10:42:59.973 +00:00 [DBG] CORS request made for path: /.well-known/openid-configuration from origin: http://localhost:8100
    2022-05-02 10:43:00.831 +00:00 [DBG] CorsPolicyService allowed origin: http://localhost:8100
    2022-05-02 10:43:00.832 +00:00 [INF] CORS policy execution successful.
    2022-05-02 10:43:00.850 +00:00 [DBG] Request path /.well-known/openid-configuration matched to endpoint type Discovery
    2022-05-02 10:43:02.760 +00:00 [DBG] Endpoint enabled: Discovery, successfully created handler: IdentityServer4.Endpoints.DiscoveryEndpoint
    2022-05-02 10:43:02.761 +00:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryEndpoint for /.well-known/openid-configuration
    2022-05-02 10:43:02.769 +00:00 [DBG] Start discovery request
    2022-05-02 10:43:04.085 +00:00 [INF] Request finished HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/.well-known/openid-configuration - - - 200 - application/json;+charset=UTF-8 4185.0806ms
    2022-05-02 10:43:04.144 +00:00 [INF] Request starting HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/api/abp/application-configuration - -
    2022-05-02 10:43:04.145 +00:00 [INF] CORS policy execution successful.
    2022-05-02 10:43:04.233 +00:00 [DBG] CORS request made for path: /api/abp/application-configuration from origin: http://localhost:8100 but was ignored because path was not for an allowed IdentityServer CORS endpoint
    2022-05-02 10:43:04.233 +00:00 [INF] No CORS policy found for the specified request.
    2022-05-02 10:43:04.282 +00:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
    2022-05-02 10:43:04.302 +00:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync() on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
    2022-05-02 10:43:04.398 +00:00 [DBG] Executing AbpApplicationConfigurationAppService.GetAsync()...
    2022-05-02 10:43:06.477 +00:00 [DBG] Executed AbpApplicationConfigurationAppService.GetAsync().
    2022-05-02 10:43:06.487 +00:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto'.
    2022-05-02 10:43:06.644 +00:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 2341.717ms
    2022-05-02 10:43:06.644 +00:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)'
    2022-05-02 10:43:06.652 +00:00 [INF] Request finished HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/api/abp/application-configuration - - - 200 - application/json;+charset=utf-8 2507.7572ms
    2022-05-02 10:44:00.151 +00:00 [INF] Request starting HTTP/1.1 GET http://dfo-dev-web.azurewebsites.net/ - -
    2022-05-02 10:44:00.228 +00:00 [INF] Executing endpoint '/Index'
    2022-05-02 10:44:00.228 +00:00 [INF] Route matched with {page = "/Index", action = "", controller = "", area = ""}. Executing page /Index
    2022-05-02 10:44:00.228 +00:00 [INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
    2022-05-02 10:44:00.236 +00:00 [INF] Executing handler method Volo.Abp.Identity.Web.Pages.Identity.Users.PpmIndexModel.OnGetAsync - ModelState is "Valid"
    2022-05-02 10:44:00.236 +00:00 [INF] Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I'm wondering if azure is causing the error?

    https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-rest-api#enable-cors

  • User Avatar
    0
    learnabp created

    Thanks, I will try to reproduce.

    Yup it was in Azure ... all good working

    thanks for your help @maliming you are awesome

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You're welcome.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07