Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants