Open vbg8exadel opened 1 year ago
Hi @vbg8exadel , sorry for the late response. I understand it's not convenient. One possible solution is to put the deployment URI into an environment variable and use it to configure the API handler. IIRC, the full URL is required by JSON:API specification.
Maybe we can improve this by inspecting the request object and extracting the current base URL out of it.
Yes, that is one option. Although there should be a way to ger it from Express router. I hope there is a way to get the base URL once in the beginning.
Description and expected behavior As per documentation in order to use REST Handler we need to provide endpoint URL. Unfortunately the only possible format is absolute URL with hardcoded protocol, hostname and port number. See the documentation at https://zenstack.dev/docs/reference/server-adapters/api-handlers/rest
While testing locally it is enough to have endpoint configured as so, but once you start deploying the same code to multiple environments, then it becomes invalid. The protocol, host, port for the endpoint URL should be detected automatically so we can add the URL context only. For example, like so:
After that I can run the server locally at http://localhost:3000, or deploy to DEV server which runs at https://dev-api.myhost.org:8080: my code will work properly, and the URLs will be pointing to correct place.
Environment (please complete the following information):