Skip to content

Commit 9c09731

Browse files
committed
Changed to allow option and head methods on the image endpoint
1 parent cce9761 commit 9c09731

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

barcoder/Controllers/ImageController.cs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class ImageController : ControllerBase
1414
{
1515

1616
[HttpGet("image.png")]
17+
[HttpOptions("image.png")]
18+
[HttpHead("image.png")]
1719
public IActionResult Get(string text, BarcodeFormat type, string logo, int width = 300, int height = 30, int rotate = 0)
1820
{
1921
try

barcoder/Startup.cs

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public void ConfigureServices(IServiceCollection services)
2424
{
2525
services.AddControllersWithViews();
2626

27+
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
28+
{
29+
builder.AllowAnyHeader()
30+
.AllowAnyMethod()
31+
.AllowAnyOrigin();
32+
}));
33+
2734
services.AddSwaggerGen(c =>
2835
{
2936
c.SwaggerDoc(_apiVersion, new OpenApiInfo { Title = _apiTitle, Version = _apiVersion });
@@ -33,6 +40,8 @@ public void ConfigureServices(IServiceCollection services)
3340
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3441
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3542
{
43+
app.UseCors("MyPolicy");
44+
3645
app.UseSwagger();
3746
app.UseSwaggerUI(c =>
3847
{

0 commit comments

Comments
 (0)