[editor] Fix Client Request API Endpoint to Work for Any Prod Port #619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[editor] Fix Client Request API Endpoint to Work for Any Prod Port
In development, the client will be served via a node process from
react-scripts
at localhost:3000 by default. The python server will be at localhost:8080 by default.In 'prod', the client will be bundled and statically served by the python server at the same port as the python server.
So, for prod we should make requests to '/api/*' which will resolve to the hostname/port of the server that served the JS.
For dev, we can just hardcode to the correct server port for now.
Testing:
yarn build
inaiconfig/python/src/aiconfig/editor/client
Then run the prod server mode:
aiconfig edit --aiconfig-path=cli/aiconfig-editor/travel.aiconfig.json --server-mode='prod'
and see the editor at localhost:8080 sending correct requests
Simultaneously, start up on another port:
ryanholinshead@Ryans-MacBook-Pro aiconfig % aiconfig edit --aiconfig-path=cli/aiconfig-editor/travel.aiconfig.json --server-mode='prod' --server-port=1234
and see the editor there as well