Is there a way to proxy api calls in electron?

Here is my situation

  1. In my web renderer, I send all api calls based on baseUrl: ‘/api’
    enter image description here

  2. In my electron main, I serve all my web static files based on ‘File://’ protocal
    enter image description here

So the problem is

How do I proxy all 'file:///api/*' api calls to a specific url, like proxy to 'http://myapiserver.com/api/*'