Skip to content

Add configurable CORS support to http command #371

Description

@youen

Description

Currently, the http command in LINO starts an HTTP server but does not provide a way to configure CORS (Cross-Origin Resource Sharing) settings. This can be problematic when the API is accessed from frontend applications running in different domains (e.g., local development with localhost:3000).

Proposal

Add support for enabling and configuring CORS headers via CLI flags. This will improve compatibility with frontend applications and make local development smoother.

Suggested Implementation

Add the following flags to the http command:

--enable-cors (boolean): Enables CORS middleware when set.

--cors-origins (string slice, default: ["*"]): Allowed origins for CORS requests.

--cors-methods (string slice, default: ["GET", "POST", "OPTIONS", "DELETE"]): Allowed HTTP methods.

--cors-headers (string slice, default: ["Content-Type", "Authorization"]): Allowed request headers.

Example usage:

lino http --enable-cors --cors-origins=http://localhost:3000/ --cors-methods=GET,POST

If --enable-cors is set and no origins are specified, it should default to *.

Implementation can use the github.com/rs/cors package to handle middleware logic.

Benefits

Enables frontend clients (especially during local development) to make cross-origin requests to the LINO HTTP server.

Avoids the need for external reverse proxies to handle CORS.

Keeps CORS configuration flexible, minimal, and CLI-driven.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions