Open Closed

Deploying Angular app to Azure Web App gives "An error has occurred! Error detail not sent by server." on first page load #10381


User avatar
0
improwise created

We have an ABP app built using the latest version of ABP - Angular for UI. When running the angular app locally against the .Host hosted in an Azure Web App everything works as it should. However, when pushing the Angular app to a Web App (not a static web app for reasons) everything works as well, except that we always get a "An error has occurred! Error detail not sent by server." at first page load. This regardless of which browser etc. This only happens on first full page load, after which everything works as it should.

There are no errors reported whatsoever in server logs, web browser console etc. If it had not been for this error message, you would have no idea that something isn't what it should be.

This happens regardless of if you are authenticated or now (authentication works fine also).

For obvious reasons we can't post any logs as there are none indicating any problem.


26 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • This popup is ABP Angular’s global HTTP error handler. On the very first full page load, the Angular UI makes a call to AbpApplicationConfigurationAppService.GetAsync() (application configuration endpoint). If that call fails (typically 401/403/500 or a blocked request), ABP shows the generic modal “An error has occurred! Error detail not sent by server.”.
    • In Azure Web App deployments, the most common reason this happens only on the first load is that the very first request from the browser is being redirected or blocked (e.g., HTTP→HTTPS redirect, missing SPA rewrite, missing/incorrect CORS/AllowedHosts, or a proxy/WAF stripping ABP error details). The follow-up request then succeeds (cached config/token/cookies already set), so it “magically” works afterward.

    Do the following fixes (they are safe and align with ABP Angular deployment expectations):

    1. Ensure your Angular site serves index.html for deep links (SPA rewrite)

      • In Azure Web App (IIS), add/verify a web.config in your Angular build output (same folder as index.html) that rewrites all non-file, non-folder routes to /index.html.
      • Without SPA rewrite, the first navigation can hit a 404/redirect chain and the config call can fail; after you click around (client-side routing), it works.
    2. Ensure the Angular app’s environment.prod.ts points to the correct backend URL (HTTPS)

      • apis.default.url must be the exact public URL of your Host (normally https://...).
      • A common first-load failure is calling the API over http:// (or wrong host) which gets redirected/blocked, while later calls appear fine due to cached baseUrl/config.
    3. If UI and Host are on different origins, fix CORS on the Host

      • On the Host, set App:CorsOrigins to include the Angular Web App origin (e.g., https://your-angular-site.azurewebsites.net) exactly.
      • Also ensure App:RedirectAllowedUrls contains your Angular URL (important for auth redirects).
    4. Verify the first failing request in the browser Network tab

      • Reload with “Disable cache” enabled.
      • Find the first request that fails (usually the application configuration call).
      • Once you see its status code and whether it’s a redirect, you can map it directly to (1)-(3) above. This is the key: the popup is just a symptom of that initial failed HTTP call.

    Sources (validated)

    • https://abp.io/docs/latest/framework/ui/angular/quick-start
    • https://abp.io/community/articles/gjcb2f1e
    • https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    improwise created

    AI response isn't valid as we have no errors and everything works fine except for first page load so should be nothing with CORS etc.

    Should add that we are using Azure Web App Linux.

  • User Avatar
    0
    improwise created

    There are a couple of 204s for

    • /openid-configuration,
    • /api/abp/application-localization?cultureName=en&onlyDynamics=false
    • /.well-known/jwks
    • /api/abp/application-configuration?includeLocalizationResources=false

    but if those are triggering this, I believe it is the error handling in ABP that is not working as it should as 204s are perfectly valid http codes to get back.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share your Angular website URL and test username&password?

    liming.ma@volosoft.com

    Thanks

  • User Avatar
    0
    improwise created

    [maliming] said: hi

    Can you share your Angular website URL and test username&password?

    liming.ma@volosoft.com

    Thanks

    It is currently in an internal (IP protected) Azure resource so that could turn out to be problematic.

    Did try to run the Angular app locally and we are getting the 204s there as well but without the "An error has occurred".

    Is there no logging behind those error messages even serverside? What/how are they triggered, something must be setting them off?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share the requests HAR file first?

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems#answer-3a1a1c4b-691e-3403-98b9-5f23fa024759

    liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    improwise created

    Research seem to indicate that this could be OAuth related. We have noticed that when running backend in debug mode (locally) we are getting frequent Exceptions in the Use() method in the XXXHttpApiHostModule. which seem to be related to the chat module. Could perhaps be related to this but that is more of a guess....

    app.Use(async (httpContext, next) => { var accessToken = httpContext.Request.Query["access_token"];

    var path = httpContext.Request.Path;
            if (!string.IsNullOrEmpty(accessToken) &&
                (path.StartsWithSegments("/signalr-hubs/chat")))
            {
                httpContext.Request.Headers["Authorization"] = "Bearer " + accessToken;
            }
    
            await next();
        });
    
  • User Avatar
    0
    improwise created

    That error message above is then followed by this usually

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can comment out this code and test if Angular works.

    And the exception should write to logs. Can you share the logs?

    Thanks.

  • User Avatar
    0
    improwise created

    Seems like disabling the Chat module makes the exceptions go away, it does not however seem to affect the error message being displayed in the app. So probably not related although you should considering creating a new ticket to handle the Chat related Exceptions.

  • User Avatar
    0
    improwise created

    [maliming] said: hi

    Can you share the requests HAR file first?

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems#answer-3a1a1c4b-691e-3403-98b9-5f23fa024759

    liming.ma@volosoft.com

    Thanks.

    Distributing HAR files will have to be considered as they contain a lot of information we might not want to share.

    Is there no way of at least getting an idea from logs etc what is triggering this error message? I assume it cant just magically appear on its own, there has be be some ABP logic somewhere catching something and then creating the message?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I haven't encountered this issue before, so I need to reproduce it. Right now, I haven't even seen any logs, so I really have no idea where the issue is.

    Do you have any ideas how I can reproduce it?

    Thanks.

  • User Avatar
    0
    improwise created

    [maliming] said: I haven't encountered this issue before, so I need to reproduce it. Right now, I haven't even seen any logs, so I really have no idea where the issue is.

    Do you have any ideas how I can reproduce it?

    Thanks.

    The lack of logs is kind of the problem here, especially considering that besides the error dialog, we have not really seen anything being broken :)

    Since there seem to be no logging behind whatever is triggering the error message, is there perhaps a way that we could temporarily modify some code just to get a feeling for what's triggering it?

    Seems to be related to Angular app being in Azure, as just calling the backend in Azure from the Angular app running locally does not produce this error message.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Would you consider making your Angular application public for 10 minutes?
    That way, we can reproduce the error online and help us identify the problem.

    Thanks.

  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    The problem is that the /getEnvConfig endpoint doesn't return the expected data.

    You can :

    1. Remove remoteEnv from environment.prod.ts if you don't want to use the dynamic-env.json feature.
    remoteEnv: {
        url: '/getEnvConfig',
        mergeStrategy: 'overwrite'
    }
    

    2, Rewrite this endpoint in your IIS or nginx..

  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    If I intercept the request and change the response, Angular no longer throws an error.

  • User Avatar
    0
    improwise created

    Thanks, will look into that. But how come this isn't, at least what we have found, more clearly logged/indicated?

    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We will show some in the console if this endpoint is wrong.

    Thanks.

  • User Avatar
    0
    improwise created

    [maliming] said: hi

    We will show some in the console if this endpoint is wrong.

    Thanks.

    Hi,

    Is this something that will be changed in the future as at least we didn't see anything in console?

    Also, how com this isn't working as we have not changed the URLs or paths as I know and they should be relative to the baseURLwhich seem to be working?

  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    We will output warning logs.

    https://github.com/abpframework/abp/pull/24815

  • User Avatar
    0
    improwise created

    Thank you, that additional info in the logs will be good to have. Can confirm that the error seem to go away once we commented out this in environment.prod.ts

    /* remoteEnv: { url: '/getEnvConfig', mergeStrategy: 'deepmerge' }*/

    That said, I still would like to know what is actually wrong here and how to get it working. Disabling functionality seems like a workaround that isn't really a solution to the problem, and increased logging of the error probably won't solve it either.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I still would like to know what is actually wrong here and how to get it working

    You have to add Rewrite for this endpoint in your IIS or nginx.

    Thanks.

  • User Avatar
    0
    improwise created

    Thanks.

    I see this is mentioned here

    https://abp.io/docs/latest/framework/ui/angular/environment

    but I think that the requirements for ABP should probably highlight more clearly that Nginx or IIS is a requirement (at least if you are using Angular). I believe that the problem here might be that for various reasons, we are running the Angular app from a Web App (linux) using node stack, which AFAIK uses Nginx to run the container, but not actually serve the content files. Because of this, we are using the startup command

    pm2 serve /home/site/wwwroot --no-daemon --spa

    Which probably does not work with remoteEnv out of the box.

    What we did now was to change the environment.prod.ts to this instead as the dynamic-env.json file in wwwroot

    remoteEnv: { url: '/dynamic-env.json', mergeStrategy: 'deepmerge' }

    Which at least seem to not cause any problems even though the dynamic-env file is being served, but we have not really looked into it more in detail except that verifying that we are not getting this error message.

    Not sure what potentia drawbacks this may have though?

    The requirements should probably be updated as well to indicate that IIS or Nginx is needed (at least for it to work out of the box) if this isn't listed.

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    We have changed this behavior so that, even without IIS or Nginx, it will no longer show errors.

    Thanks.

  • User Avatar
    0
    improwise created

    [maliming] said: hi

    We have changed this behavior so that, even without IIS or Nginx, it will no longer show errors.

    Thanks.

    Thanks.

    Please also consider if there is a need to update docs to highlight this (requirements for getting dynamic envs to work) and also considering this ticket as it seem to have been valid for a needed fix. Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.2.0-preview. Updated on February 17, 2026, 09:10
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.