Routing to Endpoint

Hello,
I have a end point service that need to be configured after the authorization is configured.
I use ServiceStack AuthFeature.
This is the code that I use:

  app.UseServiceStack(appHost);
  app.UseEndpoints(endpoints =>
  {
    //...configure endpoint /path
  });

When I navigate to the endpoint path I don’t get a response.

If I bring the “App.UseEndpoints” before the “app.UseServicestack” I manage to get a response, but the user claim is alwais unauthenticated.

How I can manage to configure Servicestack to manage that route?

Thanks in advance

Hi @Gianmaria,

Can you share more about what you want to achieve with the separate endpoint? If you want ServiceStack to handle an endpoint, are you able to define a normal route/service for the specified path?

Are you trying to migrate a previously handled route to use ServiceStack.

Any additional details would be appreciate as I’m not sure I’m following what you are trying to achieve.

Hi,
for example I use Hotchocolate side by side with Servicestack.

For configure the end point I use this code:

       app.UseRouting();
      
        app.UseServiceStack(new AppHost
        {
            AppSettings = new NetCoreAppSettings(Configuration)
        });
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapGraphQL();
        });

The command endpoints.MapGraphQL(); create a route on “/graphql” endpoint and publish “Banana Cake Pop” Ui on that address.
When I call it by the browser I don’t get any response.

I suppose is due to the middleware pipeline order.

I investigated and I found that Sharpage plugin take care of the route so is not delivered to the right endpoint.

I added a IgnorePaths in SharpPage and everythings is ok.

     Plugins.Add(new SharpPagesFeature
  {
    IgnorePaths = new List<string>(){ "/graphql/*"}
  });

Thanks.

Gianmaria

2 Likes