Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Access to XMLHttpRequest CorsOrigins production deployment #6755


User avatar
0
361apps created

Dears, we are facing a couple of issues deplying to production:

  1. Access to XMLHttpRequest at 'http://localhost:22742/AbpUserConfiguration/GetAll' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

configurations appsettings.production.json: "App": { "ServerRootAddress": "http://localhost:22742/", "ClientRootAddress": "http://localhost:4200/", "CorsOrigins": "http://localhost:4200"}

  1. the application is not wrinting the log files even through the folder on IIS is granted full access

8 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Please confirm your application environment for production. Is the local test successful?

    Execute the dotnet yourwel.dll test in the release folder to see

  • User Avatar
    0
    361apps created

    Hello @maliming, production is running IIS 10.0.17134.1 windows 10 we are checking locally actually not pulically.

    can you please guide us more about the below mentioned as this dll is not available in the release folder dotnet yourwel.dll

  • User Avatar
    0
    361apps created

    we found that the logs are showing a DB connectivity issue A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found

    even though we are using the same connectivity settings in development enviroment and it's connecting successfully

  • User Avatar
    0
    maliming created
    Support Team

    I think the application's runtime environment error caused the wrong connection string to be read. The wrong environment settings were used. appsettings.json appsettings.Production.json

  • User Avatar
    0
    361apps created

    Dear @Maliming, both setting file are identical there are no differences between them

  • User Avatar
    0
    maliming created
    Support Team

    Do not use IIS, directly in the folder of the publisher. Execute dotnet MyCompanyName.AbpZeroTemplate.Web.Mvc.dll or MyCompanyName.AbpZeroTemplate.Web.Host.dll

    See how the results are.

  • User Avatar
    0
    361apps created

    there is no such dll in the publish folder, please find below screenshot when searching for abpzerotemplate

  • User Avatar
    0
    361apps created

    solution DB string was configured to connect without user id and password, for some unknown reason in production this was not supported. changed the connection string to include user id and password and the server launched corretly.

    one more point regarding the log files if anyone checks this post if the server is not logging error on production environment follow the below steps:

    1. change the web.config aspcore paramter stdoutLogEnabled="true"
    2. create manually a folder under the published directory named "logs"