I have the basic html, for example:
<html>
<head>
<title>My App</title>
</head>
<body>
<div id="app"></div>
<script>window.API_URL = ''</script>
</body>
</html>
I need to replace '' by environment variable. Env variable will contain slashes (for example: https://website.com/api
I'm trying to use the following code but it just outputted $MY_API_URL
instead of real value and </script>
text got removed:
cat index.html | sed -i -e '/window\.API_URL =/ s/= .*/= \"${MY_API_URL}\";/' index.html
Given MY_API_URL=https://somesite.com
, I expect to get <script>window.API_URL = "https://somesite.com";</script>
.