warning
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
CORS Configuration Guide
This document describes how to configure Cross-Origin Resource Sharing (CORS) settings for the API server using both CLI commands and HTTP API endpoints.
Command Line Interface (CLI)​
Basic Usage​
cortex config [OPTIONS] [COMMAND]
Commands​
-
status
: Display all current configurationscortex config statusExample Output:
+-----------------+-------------------+| Config name | Value |+-----------------+-------------------+| allowed_origins | http://localhost |+-----------------+-------------------+| allowed_origins | https://cortex.so |+-----------------+-------------------+| cors | true |+-----------------+-------------------+
Options​
Option | Description | Example |
---|---|---|
-h, --help | Print help message and exit | |
--cors [on/off] | Toggle CORS functionality | cortex config --cors on |
--allowed_origins [origins] | Set allowed origins for CORS, comma separated without spaces | cortex config --allowed_origins http://localhost,https://cortex.so |
Examples​
-
Toggle CORS on:
cortex config --cors on -
Toggle CORS off:
cortex config --cors off -
Set allowed origins:
cortex config --allowed_origins http://localhost,https://cortex.so -
View current configuration:
cortex config status
CORS API Configuration​
This document describes the REST API endpoints available for managing CORS configurations.
Endpoints​
Get Current Configuration​
GET /v1/configs
Retrieves the current CORS configuration settings.
Response​
{ "allowed_origins": ["http://localhost:39281"], "cors": true}
Update Configuration​
PATCH /v1/configs
Updates CORS configuration settings.
Request Headers​
Content-Type: application/json
Request Body​
{ "cors": true, "allowed_origins": ["http://localhost:39281"]}
Parameters​
Field | Type | Description |
---|---|---|
cors | boolean | Enable or disable CORS |
allowed_origins | string[] | Array of allowed origin URLs |
Response​
{ "config": { "allowed_origins": ["http://localhost:39281"], "cors": true }, "message": "Configuration updated successfully"}
Example cURL Commands​
Get Configuration​
curl --location 'http://127.0.0.1:39281/v1/configs'
Update Configuration​
curl --location --request PATCH 'http://127.0.0.1:39281/v1/configs' \--header 'Content-Type: application/json' \--data '{ "cors": true, "allowed_origins": [ "http://localhost:39281" ]}'
Notes​
- Origins for CORS should be provided as comma-separated values without spaces
- The
--allowed_origins
option only takes effect when CORS is enabled
Best Practices​
- Always verify CORS status after toggling
- Double-check allowed origins to prevent security issues
- Use the
status
command to confirm changes have been applied correctly