[backend/api] Allow CORS from all origins for FallbackController (ISH-301)

This commit is contained in:
Laura Hausmann 2024-05-02 22:42:45 +02:00
parent 21c042453c
commit ba15058e5c
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 9 additions and 0 deletions

View file

@ -2,6 +2,7 @@ using System.Net;
using System.Net.Mime;
using Iceshrimp.Shared.Schemas;
using Iceshrimp.Backend.Core.Middleware;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
namespace Iceshrimp.Backend.Controllers;
@ -9,6 +10,7 @@ namespace Iceshrimp.Backend.Controllers;
[Produces(MediaTypeNames.Application.Json)]
public class FallbackController : ControllerBase
{
[EnableCors("fallback")]
[ProducesResponseType(StatusCodes.Status501NotImplemented, Type = typeof(ErrorResponse))]
public IActionResult FallbackAction()
{

View file

@ -262,6 +262,13 @@ public static class ServiceExtensions
.WithHeaders("Authorization", "Content-Type", "Idempotency-Key")
.WithExposedHeaders("Link", "Connection", "Sec-Websocket-Accept", "Upgrade");
});
options.AddPolicy("fallback", policy =>
{
policy.WithOrigins("*")
.WithMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT")
.WithHeaders("Authorization", "Content-Type", "Idempotency-Key")
.WithExposedHeaders("Link", "Connection", "Sec-Websocket-Accept", "Upgrade");
});
});
}