Open Closed

ccess to fetch at 'https://localhost:44362/api/abp/application-configuration?api-version=1.0' from origin 'https://localhost:44308' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-O #2919


User avatar
0
malfaqeeh48 created

ccess to fetch at 'https://localhost:44362/api/abp/application-configuration?api-version=1.0' from origin 'https://localhost:44308' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

  • ABP Framework version: v5.2.0
  • UI type:Blazor WebAssembly
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

9 Answer(s)
  • User Avatar
    0
    malfaqeeh48 created

    help me please i need help very very fast cuse i have a deadline

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    As I see, it's a CORS issue, did you configure cors properly for you client?

    Make sure your IdentityServer configuration is made properly. https://docs.abp.io/en/abp/5.2/Modules/IdentityServer#client

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    You can configure it with UI:

  • User Avatar
    0
    malfaqeeh48 created

    As I see, it's a CORS issue, did you configure cors properly for you client?

    Make sure your IdentityServer configuration is made properly. https://docs.abp.io/en/abp/5.2/Modules/IdentityServer#client

    iam still on localhost server run time iis ???

  • User Avatar
    0
    malfaqeeh48 created

    You can configure it with UI:

    the problem is I can not to access to this page because the error change port number for from 4307 to 4308 and i got this error when I click f12 inspect console and that happened automatically this is not the first time happened

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    If you're working on localhost, please check your IdentityServerDataSeedContributor.cs class before running DbMigrator. That class is placed under IdentityServer folder under Domain project by default. All Clients are defined there and they're seeded to run your app properly at the initial state.

    Make sure the following code block exits and blazor URL is configured properly in appsettings.json of DbMigrator project.

      var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"];
            if (!blazorClientId.IsNullOrWhiteSpace())
            {
                var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/');
    
                await CreateClientAsync(
                    name: blazorClientId,
                    scopes: commonScopes,
                    grantTypes: new[] { "authorization_code" },
                    secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(),
                    requireClientSecret: false,
                    redirectUri: $"{blazorRootUrl}/authentication/login-callback",
                    postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback",
                    corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") }
                );
            }
    

    After configuring everything well, run the DbMigrator once to seed client options.

    Also, please check appsettings.json file under your HttpApi.Host project. There should be a section like that:

     "App": {
        "CorsOrigins": "https://*.yourproject.com"
      },
    

    You can separate CorsOrigins with coma (,), make sure there is your blazor url.

  • User Avatar
    0
    malfaqeeh48 created

    If you're working on localhost, please check your IdentityServerDataSeedContributor.cs class before running DbMigrator. That class is placed under IdentityServer folder under Domain project by default. All Clients are defined there and they're seeded to run your app properly at the initial state.

    Make sure the following code block exits and blazor URL is configured properly in appsettings.json of DbMigrator project.

      var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; 
            if (!blazorClientId.IsNullOrWhiteSpace()) 
            { 
                var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); 
     
                await CreateClientAsync( 
                    name: blazorClientId, 
                    scopes: commonScopes, 
                    grantTypes: new[] { "authorization_code" }, 
                    secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), 
                    requireClientSecret: false, 
                    redirectUri: $"{blazorRootUrl}/authentication/login-callback", 
                    postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback", 
                    corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") } 
                ); 
            } 
    

    After configuring everything well, run the DbMigrator once to seed client options.

    Also, please check appsettings.json file under your HttpApi.Host project. There should be a section like that:

     "App": { 
        "CorsOrigins": "https://*.yourproject.com" 
      }, 
    

    You can separate CorsOrigins with coma (,), make sure there is your blazor url.

    yes I checked them all everything is good and that's code already build by abp suite and I didn't change anything's in these files

  • User Avatar
    0
    malfaqeeh48 created

    i don't know why that's problem happened with me I didn't make any change except the the db but I made update db on the cli and i made run for dbmigrator this is the last time happened before multiple days so help please to solve this situation

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    Open the appsettings.json of your project running at 'https://localhost:44362'. Go to the CORS section and add localhost:44308.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11