Using a remote host as a local_server.backend

I have a backend configured that I am using in production. I would like to use the same backend in my local development environment.

I have configured the backend as follows:

[local_server]
[local_server.backends]
[local_server.backends.<my backend>]
url = "<my backend's api url>"

And when I start the local service with fastly compute serve, it seems to connect to the backend:

✓ Running local server

INFO: Listening on http://127.0.0.1:7676

INFO: Command output:
--------------------------------------------------------------------------------
2023-09-24T18:53:32.945566Z  INFO checking if backend '<my backend>' is up
2023-09-24T18:53:33.250933Z  INFO backend '<my backend>' is up
2023-09-24T18:53:33.251065Z  INFO Listening on http://127.0.0.1:7676

The actual request my local service makes looks fine, except that the request body is omitted. I’m wondering if I need to do something special with the local server to configure TLS in order to get the request body to send?

Hi @crajcan

All looks fine as far as what you’ve explained so far.

I think we’d need to see your code to ascertain any issues.

You can either email an example from your code to support@fastly.com or alternatively please use Fiddle - Fastly to create a reduced test case.

Many thanks!

Hey @Integralist, thanks for pointing me to the Fastly Fiddle.

When I put in my origin server it rejected my url as invalid which made me realize my local config had the url set as:

[local_server.backends.<my_backend>]
url = "https://<my_domain>.com:443/<my_endpoint_path_prefix>"

Once I remove the endpoint path prefix it works fine. Still not sure why that broke things. If I get the time I’ll email some code over

Hi @crajcan

Thanks for the update!

Yes, what you had defined would have caused an error.

The url field is a little misleading because it’s supposed to be a scheme/hostname combination but not the ‘path’ segment, as the request’s path is appended to the backend url.

Something for us to clarify in our documentation:

UPDATE:
I stand corrected! I just re-read our documentation and noticed it does say a path prefix is allowed, so yes please @crajcan if you could send support@fastly.com your code and a link to this forum thread that would be greatly appreciated.

:wave:

I’ve successfully tested the use of a path-prefix (see screenshot below), so I would recommend emailing support@fastly.com as they’ll be able to take a look at your source code and check your configuration to see if there’s anything mis-configured that would cause this to not work.