Open Closed

AbpCookieConsentOptions does not work #9762


User avatar
0
arezoo_a created

Hi everyone,

I'm using Volo.Abp.Gdpr.Web version 9.0.5 and have configured the cookie consent options like this: context.Services.Configure<AbpCookieConsentOptions>(options => { options.IsEnabled = true; options.CookiePolicyUrl = "http://www.google.com"; options.PrivacyPolicyUrl = "http://www.google.com"; options.Expiration = TimeSpan.FromDays(180); });

I also added the middleware after the authentication middleware:

app.UseAuthentication(); app.UseAbpCookieConsent();

However, my issue is that the provideGdprConfig() method in app.module.ts does not seem to bind to these backend options. The cookie banner shows up, but the CookiePolicy and PrivacyPolicy links are missing.

If I set these options manually in the Angular module, it works correctly: provideGdprConfig( withCookieConsentOptions({ cookiePolicyUrl: 'www.google.com', privacyPolicyUrl: 'www.google.com', }), ),

Also, when I check the output of the API endpoint /api/abp/application-configuration, the cookie options do not appear in the response. Has anyone encountered this or knows how to ensure the frontend binds properly to the backend cookie consent configuration?

Thanks in advance.


9 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To ensure that the Angular frontend receives the backend's AbpCookieConsentOptions (such as CookiePolicyUrl and PrivacyPolicyUrl), these options must be exposed via the application configuration API. By default, ABP's GDPR module does not automatically send the backend cookie consent options to the Angular client through /api/abp/application-configuration. This is why you do not see these options in the API response, and the frontend does not bind to them unless you set them manually in provideGdprConfig.

    Solution:

    1. Manual Synchronization Required:
      Currently, you need to manually keep the backend and frontend cookie consent options in sync. The backend configuration (AbpCookieConsentOptions) is used for the server-side rendering and .NET-based UI, but the Angular module expects its own configuration via provideGdprConfig.

    2. How to Synchronize:

      • Set the options in both places:
        • In your backend, configure AbpCookieConsentOptions as you already do.
        • In your Angular app, set the same values in provideGdprConfig.
      • If you want to avoid duplication, you can implement a custom Angular service that fetches the values from a custom API endpoint you expose from your backend, then passes them to provideGdprConfig at runtime.
    3. Why This Happens:
      The ABP GDPR module's backend options are not automatically included in the application configuration sent to the Angular client. This is by design, as the Angular module is decoupled and expects explicit configuration.

    Summary:
    There is no built-in mechanism in ABP 9.0.5 to automatically bind backend AbpCookieConsentOptions to the Angular frontend. You must set the options in both places or implement a custom solution to fetch and apply them on the client.

    Sources:


    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
    maliming created
    Support Team Fullstack Developer

    hi

    I think you need to set up both the backend and Angular at the same time.

    Thanks.

  • User Avatar
    0
    arezoo_a created

    Thank you for your answer. Both the backend and Angular (GdprConfigModule and provideGdprConfig) have been configured, but it still does not work.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Which UI page doesn't work?

    MVC or angular?

    Thanks.

  • User Avatar
    0
    arezoo_a created

    Hi, Angular doesn't work.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will ask our Angular team.

    Thanks.

  • User Avatar
    0
    sumeyye.kurtulus created
    Support Team Angular Expert

    Hello, The expected behavior here is actually met. These links are configured inside the provider function as you mentioned above.

     provideGdprConfig(
          withCookieConsentOptions({
            cookiePolicyUrl: 'https://google.com',
            privacyPolicyUrl: 'https://google.com',
          }),
        ),
    
  • User Avatar
    0
    arezoo_a created

    as I mentioned links show up only if I set them directly in provideGdprConfig. So what is the purpose of AbpCookieConsentOptions? what if I want to configure links form backend?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You need to configure it in backend.

    see https://abp.io/docs/latest/modules/gdpr#abpcookieconsentoptions

    Some components and features need to be configured in both the backend and Angular at the same time.

    Thanks.

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 08, 2025, 09:55