Starts in:
1 DAY
23 HRS
50 MIN
13 SEC
Starts in:
1 D
23 H
50 M
13 S
Open Closed

CORS new api service #3347


User avatar
0
mmaldonado@emscltd.com created

ABP Framework version: v5.3.0 UI type: angular DB provider: EF Core Identity Server Separated (Angular): yes

2022-06-29 14:48:42.714 -05:00 [INF] No CORS policy found for the specified request. 2022-06-29 14:48:42.977 -05:00 [INF] Request finished HTTP/2 GET https://localhost:44322/swagger/v1/swagger.json - - - 200 - application/json;charset=utf-8 2675.0220ms

My environment

I have this configuration over Ports:

WebGateway: https: 44325 AuthServer: https: 44322 IdentityService: https: 44388 ProductService: https: 44361 NewService: https: 44752

AngularClient: http: 4200 ReactClient: http: 5200

CORS: WebGateway: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" AuthServer: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361", IdentityService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" ProductService: "https://localhost:44325,https://localhost:44353" NewService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361"

Result:

NewService: Swagger is working, and openApi definition is working ProductService: Swagger is working, and openApi definition is working

WebGateway: works over all old services, but when I try to switch to NewService Api definition from WebGateway it gives me a CORS error, if I pick ProductService it works, that not makes sense to me, it has be something else in between


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you try to add https://localhost:44361 to the CORS list?

  • User Avatar
    0
    hakan.uskaner created

    I have the same error, please look here: https://support.abp.io/QA/Questions/3310/Howto-integrate-a-standard-template-pro-solution-as-new-service-in-a-microservice-solution

    I did try to add my newservice to all appsettings, without success. i also did replace the port number of product-service with my new service in ocelot.json without success. so from my point liangshiwei advise didn't work for me

  • User Avatar
    -1
    liangshiwei created
    Support Team Fullstack Developer

    Hi, @hakan.uskaner

    CORS request made for path: /swagger/v1/swagger.json from origin: https://localhost:44325 but was ignored because path was not for an allowed IdentityServer CORS endpoint

    You can open the identity server management page, edit the swagger client , and add the new service URL address here.

  • User Avatar
    1
    hakan.uskaner created

    "app.UseCors();" was missing in the NewServiceHttpApiHostModule in OnApplicationInitialization.

    After adding it ,it works. Seems to be an issue in abp-cli.

  • User Avatar
    0
    mmaldonado@emscltd.com created

    thanks a lot app.UseCors was the fix

  • User Avatar
    0
    mmaldonado@emscltd.com created

    just to confirm based on your experience, could you write me which should be the CORS on each piece?

    for example : on AuthServer => what should we have? Gateways, Services, SwaggerClients and other Clients? on IdentityService => what should we have? on NewServices => what should we have? on Gateways => what should we have?

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