Modern embedded Shopify apps are built with JWT session tokens that need to be passed to every server request. The token needs to be fetched right before the request. Without token, all Ajax requests to the server will fail.
Solution
This PR introduces request interceptor support. It allows inserting the async function between every fetch request. Inside this function, you can do some preparation for requests and add custom headers. I already proposed the same API for Turbo (https://github.com/hotwired/turbo/pull/177).
Problem
Modern embedded Shopify apps are built with JWT session tokens that need to be passed to every server request. The token needs to be fetched right before the request. Without token, all Ajax requests to the server will fail.
Solution
This PR introduces request interceptor support. It allows inserting the async function between every fetch request. Inside this function, you can do some preparation for requests and add custom headers. I already proposed the same API for Turbo (https://github.com/hotwired/turbo/pull/177).
Example usage