Administers tenant-specific CORS policies in Orchard Core. Covers CorsSettings, CorsPolicySetting, recipe steps, deployment, and secure origin restrictions.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate secure configuration and code for the Orchard Core CORS module.
OrchardCore.Cors feature. The module has no declared feature dependencies.app.UseCors() at Orchard Core's CORS pipeline order and configures ASP.NET Core CorsOptions from tenant site settings.ManageCorsSettings permission (Administrator by default).CorsSettings). There is no appsettings.json configuration section for CORS; use the admin UI or the settings recipe step.CorsPolicySetting has a name, origin, header, method, credentials, default-policy, and exposed-header settings.AllowedOrigins entry of *. At runtime, CorsOptionsConfiguration skips a policy that has both AllowCredentials and AllowAnyOrigin (for example one imported by a recipe) and logs a warning.OrchardCore.Deployment when CORS site settings must be exported by a deployment plan.{ "steps": [...] } format.sealed modifier, except View Models.{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Cors"
],
"disable": []
}
]
}
Create a policy under Settings → Security → Cross-Origin Resource Sharing and configure:
| Setting | Guidance |
|---|---|
| Name | Use a stable descriptive name such as PublicApi. |
| Allowed origins | Use complete origins such as https://app.example.com. |
| Allowed methods | Limit to the verbs required by the browser client. |
| Allowed headers | Allow only client headers the API actually accepts. |
| Allow credentials | Enable only for trusted, authenticated origins. |
| Exposed headers | List response headers browser JavaScript may read. |
| Default policy | Mark one policy when all endpoints should use it. |
The policy editor refuses wildcard-origin policies that also allow credentials and shows a security warning. Origins are a scheme, host, and optional port only, with no path or trailing slash. An empty allowed list permits nothing for that category unless the matching Allow any option is on.
{
"steps": [
{
"name": "feature",
"enable": [ "OrchardCore.Cors" ]
},
{
"name": "settings",
"CorsSettings": {
"Policies": [
{
"Name": "Frontend",
"AllowAnyOrigin": false,
"AllowedOrigins": [ "https://app.example.com" ],
"AllowAnyHeader": false,
"AllowedHeaders": [ "Content-Type", "Authorization" ],
"AllowAnyMethod": false,
"AllowedMethods": [ "GET", "POST" ],
"AllowCredentials": true,
"IsDefaultPolicy": true,
"ExposedHeaders": [ "X-Pagination-Total" ]
}
]
}
}
]
}
Recipe and deployment imports write the site settings directly and skip the admin validation. Define at most one default policy, never combine credentials with a wildcard origin, and reload an already-running tenant after importing.
The settings are stored on the tenant site as CorsSettings:
using OrchardCore.Cors.Settings;
var settings = new CorsSettings
{
Policies =
[
new CorsPolicySetting
{
Name = "PublicApi",
AllowedOrigins = ["https://app.example.com"],
AllowedMethods = ["GET", "POST"],
AllowedHeaders = ["Content-Type", "Authorization"],
ExposedHeaders = ["X-Request-Id"],
AllowAnyOrigin = false,
AllowAnyMethod = false,
AllowAnyHeader = false,
AllowCredentials = true,
IsDefaultPolicy = true,
},
],
};
Do not write this model directly from an arbitrary controller. Use the admin UI or a service that deliberately updates tenant site settings and releases the shell.
CorsService is registered as a singleton and exposes GetSettingsAsync.
using OrchardCore.Cors.Services;
using OrchardCore.Cors.Settings;
namespace MyModule.Services;
public sealed class CorsPolicyReporter
{
private readonly CorsService _corsService;
public CorsPolicyReporter(CorsService corsService)
{
_corsService = corsService;
}
public async Task<IEnumerable<CorsPolicySetting>> GetPoliciesAsync()
{
var settings = await _corsService.GetSettingsAsync();
return settings?.Policies ?? [];
}
}
The module establishes the configured ASP.NET Core policies. Apply a named policy to an endpoint only when it should not use the default policy.
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
namespace MyModule.Controllers;
[ApiController]
[Route("api/catalog")]
public sealed class CatalogController : ControllerBase
{
[HttpGet]
[EnableCors("PublicApi")]
[AllowAnonymous]
public IActionResult Get()
{
return Ok();
}
}
The policy name must exactly match a policy configured in CorsSettings.
When OrchardCore.Deployment is enabled, the module registers a site-settings deployment step labelled Cors settings. Add that step to a deployment plan to export tenant CORS policies; the exported recipe uses the same settings step and CorsSettings object shown above.
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Cors",
"OrchardCore.Deployment"
],
"disable": []
}
]
}
AllowAnyOrigin and AllowCredentials.| Symptom | Check |
|---|---|
| No CORS headers | Verify the feature is enabled and the endpoint selects a valid named or default policy. |
| Browser preflight fails | Add only the requested method and headers to the selected policy. |
| Policy is missing after save | Correct the invalid wildcard-origin plus credentials combination. |
| Setting change has no effect | Confirm the tenant shell was released after updating settings. |
| Preflight rejected | Compare the Origin header exactly (scheme and port) and allow every header in Access-Control-Request-Headers. |
API call from the SPA returns 401 | CORS does not authenticate; send a bearer token for the Api scheme (see orchardcore-openid). |
Test a preflight without a browser:
curl -i -X OPTIONS "https://cms.example.com/api/content/abc" \
-H "Origin: https://app.example.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: authorization,content-type"
Official Orchard Core videos shown on the documentation page:
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-corsfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job