#Replacing a certain link

1 messages · Page 1 of 1 (latest)

still raptor
#

So I have an application that uses an mini api written in php. Im using a local link on my dev server to get the api script and I want to change this link when I build the app.
How do I basically string replace a certain link so I can for example use "$" as the api path like this: fetch('$/api.php'... which will get replace in dev mode with path/to/devapi/api.php and when building with api/api.php for example.

queen elk
#

I recommend you source the url from an environment variable, using a .env.local (not checked in) to provide the development value. When deployed, that environment file will not be present, allowing a default (production) value to take effect.