Issue with SignalR client functionality following update to .NET Core 3.1版本

Upon updating our server-side code to asp.net core 3.1, we encountered an issue with the javascript client for signalr (@microsoft/signalr 3.1.0).

The errors we are facing are:

https://i.sstatic.net/ITZyK.png

Here is the code snippet for the hub initialization:

https://i.sstatic.net/u2oEx.png

Our access token factory retrieves the token from msal. (The authentication process remains unchanged and the token is correctly received) Any assistance with this would be highly appreciated.

Answer №1

I encountered an issue while using the @aspnet/signalr javascript client, which is the same version as the Nuget package on the server. Strangely, I couldn't get it to work with @microsoft/signalr.

Upon investigation, I realized that the authentication was failing due to a missing AllowCredentials on Cors in the startup configuration:

public void ConfigureServices(IServiceCollection services)
{
        services
            .AddControllers();
        services.AddCors(options => options.AddPolicy("CorsPolicy", builder =>
        {
            builder
                .AllowAnyMethod() //customize as needed
                .AllowAnyHeader() //customize as needed
                .AllowAnyOrigin() //customize as needed
                .AllowCredentials();
        }));
        services.AddSignalR();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseHttpsRedirection();

        app.UseRouting();

        app.UseAuthorization();
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Connect the names of the sheets with the data in the tables

I have a simple question: I want to connect specific sheet names in my workbook with a table that contains a range of dates. The sheet names should be something like "blablabla" + Table@1. Although I have attempted to design a solution, it doesn't se ...

Improving a lengthy TypeScript function through refactoring

Currently, I have this function that I am refactoring with the goal of making it more concise. For instance, by using a generic function. setSelectedSearchOptions(optionLabel: string) { //this.filterSection.reset(); this.selectedOption = optionLa ...

What is the best way to transform a synchronous function call into an observable?

Is there a conventional method or developer in RxJS 6 library that can transform a function call into an observable, as shown below? const liftFun = fun => { try { return of(fun()) } catch (err) { return throwError(err) } ...

Unable to perform type casting in Typescript

I recently dived into the world of TypeScript by picking up a book titled Typescript Revealed (Published in February 2013). Chapter 2 caught my attention with a section on "Casts" featuring an intriguing example: var a : int = <int>SomeNumberAsAStri ...

How do you properly include a new property in an Object using Typescript?

I am currently delving into the world of typescript. After exploring various sources like this one and that one, as well as trying out multiple solutions, I have encountered a challenge. I have a variable named incomingArticleObject which needs to be of ty ...

Utilizing a Map with Angular's ngFor

Currently, I am working with Ionic 3, which utilizes Angular and TypeScript. My goal is to use ngFor with a Map type in my project. Below is what I have implemented so far: interface IShared_Position { lat: number; lng: number; time: number; ...

Steps for confirming whether each element in the array includes the specified search string using Typescript and protractor

How can I verify if each element in an array contains a specific search string in Typescript/Protractor? The issue I faced was that the console statements were returning false because they searched for exact matches instead of the search string. Any sugg ...

Having trouble uploading a PNG image (logo) with Cypress

I have been attempting to upload a png file using Cypress and here is what I have tried so far: Cypress.Commands.add('upload_image', (fileName, selector) => { return cy.get(selector).then(subject => { return cy.fixture(fileName, &apo ...

Tips for implementing a decorator in a TypeScript-dependent Node module with Create-React-App

I am working on a project using TypeScript and React, which has a dependency on another local TypeScript based project. Here are the configurations: tsconfig.json of the React project: "compilerOptions": { "target": "esnext& ...

Issue: Angular ERROR TypeError - Cannot access the property 'push' of a null value

In my code, I have a property called category = <CategoryModel>{};. The CategoryModel model looks like this: export class CategoryModel { public name: string; public description: string; public image: string; public products?: ProductModel[]; ...

Is there a reason for TypeScript compiler's inability to effectively manage filtering of nested objects?

Perhaps a typical TypeScript question. Let's take a look at this simple filtering code: interface Person { id: number; name?: string; } const people: Person[] = [ { id: 1, name: 'Alice' }, { id: 2 }, { id: 3, name: 'Bob&apos ...

The test.ts file does not contain any type definitions

While I am able to successfully utilize my types in .ts files, I am facing difficulties in understanding why it's failing in .test.ts files, even though both files are located in the same folder. Check out the code in the .ts file below: https://i.s ...

Employ a class decorator to modify methods within a subclass

Is there a way to utilize class decorators in order to modify the methods of subclasses for the decorated class? This particular example showcases how to alter the class's own methods, but does not extend to its subclasses: export function guardAllNo ...

Performing a series of HTTP requests within a single @ngrx/effect

I need some guidance as I am new to @ngrx and feeling a bit lost in understanding how it should be used. Let's assume we have an effect named PlaceOrderEffect In this effect, my goal is to handle each request in a specific order. processOrder$ = cre ...

When trying to check a condition in Angular using a boolean, a TypeError is generated stating that a stream was expected instead of the provided 'false' value

Error: In global-error-handler.ts file at line 42, a TypeError has occurred. It states: "You provided 'false' where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable." Below is the s ...

The FOR UPDATE clause is not functioning as intended in the SELECT query

I have been working on isolating my database to prevent multiple servers from reading or updating data in the same row. In order to achieve this, I have structured my query like so: SELECT * FROM bridge_transaction_state as bridge WHERE bridge.state IN (&a ...

Encountering a warning message in Vue 3 Migration Build using Typescript: Error in finding export 'default' (imported as 'Vue') within the 'vue' package

I've been working on migrating my vue2 application to Vue3 using the Migration Build. I diligently followed the steps outlined in the documentation available at https://v3-migration.vuejs.org/migration-build.html, but despite that, I still keep encoun ...

"What are the benefits of utilizing Dependency Injection tokens within Angular 4 and when is the ideal time to implement

I have been exploring the concept of using InjectionToken for injecting environment variables (plain objects) into a service. I find myself puzzled as to the reasons and methods for incorporating tokens in Dependency Injection. Despite my efforts to resear ...

The inversify middleware is executed a single time

I utilize Inversify for object binding in the following manner: container.applyMiddleware(loggerMiddleware); let module = new ContainerModule((bind: interfaces.Bind) => { bind<Logger>(TYPES.Logger).toConstantValue(logger); bind<ILogger ...

What is the solution to the error message stating that the property 'pipe' is not found on the OperatorFunction type?

I implemented the code based on RxJS 6 documentation while working with angular 5, RxJS 6 and angularfire2 rc.10. However, I encountered the following error: [ts] property 'pipe' does not exist on type 'OperatorFunction<{}, [{}, user, str ...