Getting error – localhost is currently unable to handle this request. HTTP ERROR 502 – GraphQL run on Visual Studio 2022 – Hotchocolate

Getting error – localhost is currently unable to handle this request. HTTP ERROR 502 – GraphQL run on Visual Studio 2022 – Hotchocolate


0

I am trying to execute a simple default Graphql app on Visual studio 2022 on .net 6 and 7.
When the app is executed from visual studio I get the error "localhost is currently unable to handle this request. HTTP ERROR 502". I’m using HotChololate.aspnetcore (13.5.1)

App URL "https://localhost:64264/graphql"

Note: I have graphql app developed on .net 6 and later when I installed .net 7 and started to create new apps on .net 6 or .net 7. The app is not loading and throwing the error.

Below is the Query.cs page

namespace GraphQL_Sample.Schema.Queries
{
    public class Query
    {
        public string Welcome()
        {
            return "Simple GraphQL App";
        }
    }
}

Below is the Program.cs

using GraphQL_Sample.Schema.Queries;

var builder = WebApplication.CreateBuilder(args);
{

    builder.Services.AddGraphQLServer()
        .AddQueryType<Query>();
}

var app = builder.Build();
{

    app.MapGraphQL();

    app.Run();
}

Below is the content for appsettings.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Below is the content of launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:64264",
      "sslPort": 0
    }
  },
  "profiles": {
    "GraphQL_Sample": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5208",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Below is the error page.

enter image description here

I tried using the solution from below link to use AddCors() and UseCors(). But still didn’t work.

How to enable CORS in ASP.net Core WebAPI


Load 3 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *