Joep van den Bogaert
01/29/2025, 1:01 PM.serve
. In order for this to work, I need to add a custom auth header to all communication with the server. Is that possible?Marvin
01/29/2025, 1:01 PM.serve
method. However, you can configure CORS settings on a self-hosted Prefect server to control which headers are allowed during requests. This might indirectly help with allowing custom headers if you're using CORS.
Here's a concise approach to achieve your goal:
1. CORS Configuration: Ensure that your server's CORS settings allow the necessary headers. You can set server.api.cors_allowed_headers
to include your custom header. More details can be found in the Prefect documentation on CORS settings.
2. Custom Client: If you need to send custom headers from your client, you might need to modify the HTTP client code in your application to include these headers when making requests to the Prefect server.
3. Explore Prefect Client: You can look into using or extending Prefect's client to include custom headers by default. Check the Prefect client API for methods that allow setting headers.
For further exploration, you might want to look into Prefect's GitHub repository or the Prefect documentation for more implementation details and examples.Joep van den Bogaert
01/29/2025, 1:05 PMserve
, for which this would be easier?Marvin
01/29/2025, 1:05 PM.serve
is proving cumbersome due to authentication header requirements, there are alternative methods to run Prefect flows that might be more flexible:
1. Local Process Execution: You can run flows in local processes, which allows you to have complete control over the HTTP client used for communication. This setup can be configured to include custom headers as needed. More information can be found here.
2. Prefect Deployment: Instead of using .serve
, you can deploy flows using Prefect's deployment features. This involves creating a deployment object using the flow.to_deployment()
method, which offers similar options to .serve
but might provide more flexibility in managing custom configurations such as headers.
3. Custom Client Configuration: If you're running flows programmatically, you can configure the Prefect client to include custom headers. This might involve extending or wrapping the client to ensure headers are included in each request.
These alternatives may provide a more straightforward path to include custom authentication headers in your flow execution setup. You can explore more about Prefect deployments and configurations in the Prefect documentation.