Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

fix: add cors and allowed_origins to server standalone parameters #2177

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

vansangpfiev
Copy link
Contributor

Describe Your Changes

This pull request refactors the server setup and configuration process in the engine/main.cc file by introducing a ServerParams struct and a SetupServer function. Additionally, it updates command-line argument handling and help text to reflect these changes.

Key changes include:

Refactoring server setup:

  • Introduced the ServerParams struct to encapsulate server parameters such as server_host, server_port, api_keys, cors, and allowed_origins. ([engine/main.ccL63-R102](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L63-R102))
  • Added the SetupServer function to handle server configuration updates based on the ServerParams struct. ([engine/main.ccL63-R102](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L63-R102))
  • Modified the RunServer function to no longer accept host and port parameters, as these are now handled by SetupServer. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L84-L100), [[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L571-R600))

Updating command-line argument handling:

  • Updated command-line argument parsing to populate the ServerParams struct instead of individual variables. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L464-R486), [[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L480-R512), [[3]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L502-R542))
  • Added support for new command-line arguments --cors and --allowed_origins. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L480-R512), [[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L502-R542))

Improving help text:

  • Updated the help text to include the new --cors argument and renamed --api_configs to --api_keys. ([engine/main.ccL437-R459](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L437-R459))

Minor changes:

  • Added a missing newline at the end of the AreUrlPathsEqual function in engine/utils/string_utils.h. ([engine/utils/string_utils.hR231](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-7b4479b6eba1e98453848526c53fda755811ed5017fa743307d6ed174a0ee580R231))

Fixes Issues

  • Closes #
  • Closes #

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

@vansangpfiev vansangpfiev merged commit ae43c53 into dev Mar 26, 2025
8 checks passed
@vansangpfiev vansangpfiev deleted the s/fix/server-params branch March 26, 2025 07:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants