asp.net with vue js FsLightbox lybrary Access to XMLHttpRequest origin has been blocked by CORS policy

diaaaldin qosa 0 Reputation points
2024-07-31T21:15:10.8666667+00:00

asp.net with vue js FsLightbox lybrary Access to XMLHttpRequest at 'https://localhost:44347/CarImages/3e0da2fa7fd0417ea2e2f4678229e264Logo.png' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. error

when use FsLightbox library show this error , im use this images path in another slider its run good and im use another images from internet to FsLightbox also run good this problem just appear when use my images paths with FsLightbox !!??

// this is policy code from program.cs 

builder.Services.AddCors(options =>
{
    options.AddPolicy(name:"MyAllowSpecificOrigins",
       builder =>
       {
           builder.WithOrigins("http://localhost:5173")
            .AllowAnyMethod()
            .AllowAnyHeader()
            .SetIsOriginAllowedToAllowWildcardSubdomains();
       });
});

/////////////////////

// this in vue js FsLightbox like documntation
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,413 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
946 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
320 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 27,701 Reputation points
    2024-07-31T22:07:13.5866667+00:00

    In ASP.NET Core the static file handler returns static files like images. You'll need to configure the static file handlers. I found the following article when doing a Google search for static file handler core and CORS.

    https://www.bytefish.de/blog/aspnetcore_static_files_cors.html

    0 comments No comments