Open Closed

Problem on the Angular app auth system #8477


User avatar
0
ruicaetano created

Dear sirs,

I have a project that works well with the abp studio. when i install on a iis server, the swagger app works fine. the angular app, also runs. but when i try to login, i get an http 400 error on the angular app. i have 3 web sites, but the auth is not running so i'm using only one.

When i want to test via swagger i can authenticate. also i can authenticate on the backoffice app. But i get this error:

the angular web.config:

<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect" stopProcessing="true"> <match url="getEnvConfig" /> <action type="Redirect" url="dynamic-env.json" /> </rule> <rule name="Angular Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="./index.html" /> </rule> </rules> </rewrite> </system.webServer> </configuration>

The dynamic-env.json: { "apiUrl": "https://apilogistics.example.com", "issuer": "https://logistics.example.com", "clientId": "logistics_App" }

Also, i dont' know if i need the auth website and if yes, what files should i put there? I think that this part is not well documented or at least i can't find it anywhere.

BEst regards

  • ABP Framework version: v8.3.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue: https://apilogistics.example.com/Error?httpStatusCode=400

9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You have to run these three websites.

    AuthServer, API, and angular app.

    Please share the logs.txt of the 400 error.

    https://abp.io/docs/commercial/latest/startup-templates/application/deployment-iis?UI=MVC&DB=EF&Tiered=Yes https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-9.0&tabs=visual-studio

    Thanks.

  • User Avatar
    0
    ruicaetano created

    hi maliming

    I've made a mistake. i'm not using tiered. In my project, i don't have the authserver project.

    I can authenticate on my swagger app. I can't on the angular app

    Warm regards

    You have to run these three websites.

    AuthServer, API, and angular app.

    Please share the logs.txt of the 400 error.

    https://abp.io/docs/commercial/latest/startup-templates/application/deployment-iis?UI=MVC&DB=EF&Tiered=Yes https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-9.0&tabs=visual-studio

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    ok, Please share the full logs.txt of your applications.

    Thanks.

    liming.ma@volosoft.com

  • User Avatar
    0
    ruicaetano created

    Hi Maliming

    I dont' have any logs.txt file in my development machine nor on the server i'm trying to deploy.

    Warn regards

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I dont' have any logs.txt file in my development machine nor on the server i'm trying to deploy.

    Please check your Program.cs, the Logs.txt is configured. You can set the .MinimumLevel.Debug() to see more logs.

    .WriteTo.Async(c => c.File("Logs/logs.txt"))

    
    public class Program
    {
        public async static Task<int> Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                .WriteTo.Async(c => c.File("Logs/logs.txt"))
                .WriteTo.Async(c => c.Console())
                .CreateBootstrapLogger();
    
            try
            {
                Log.Information("Starting web host.");
                var builder = WebApplication.CreateBuilder(args);
                builder.Host
                    .AddAppSettingsSecretsJson()
                    .UseAutofac()
                    .UseSerilog((context, services, loggerConfiguration) =>
                    {
                        loggerConfiguration
                            .MinimumLevel.Debug()
                            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                            .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
                            .Enrich.FromLogContext()
                            .WriteTo.Async(c => c.File("Logs/logs.txt"))
                            .WriteTo.Async(c => c.Console())
                            .WriteTo.Async(c => c.AbpStudio(services));
                    });
                await builder.AddApplicationAsync<MyProjectNameWebModule>();
                var app = builder.Build();
                await app.InitializeApplicationAsync();
                await app.RunAsync();
                return 0;
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly!");
                return 1;
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
    }
    
  • User Avatar
    0
    ruicaetano created

    My logs.txt has only this:

    2024-11-25 17:47:17.122 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-25 19:00:53.923 +01:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-25 18:11:27.428 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-27 02:30:42.759 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-27 16:01:41.359 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-28 15:27:00.806 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-28 16:22:57.155 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-28 16:26:35.844 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-11-29 22:55:14.283 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-01 10:48:12.210 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-02 16:09:13.707 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-03 21:23:55.509 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-05 03:23:41.662 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-06 20:11:38.773 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-08 14:32:58.605 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-11 17:51:37.961 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-13 06:09:56.235 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-14 14:31:20.516 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-15 21:17:50.541 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-17 05:56:20.641 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-18 19:55:52.328 +00:00 [INF] Starting amce.logistics.HttpApi.Host. 2024-12-20 06:54:17.003 +00:00 [INF] Starting amce.logistics.HttpApi.Host.

    Can you please tell me how should i configure the auth in the angular app, since i don't have the authserver project?

    Warm regards

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a screenshot of your solution structure?

    How many web projects are in your solution?

  • User Avatar
    0
    ruicaetano created

    Hi Maliming

    These are the .net projects:

    The Angular project is this:

    It's only one web project

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I see, Please share the Program.cs of your logistics.HttpApi.Host project.

    We need to output more logs.

    Thanks.

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