Hi all, I am having a problem with creating a ‘Deploy to DO’ button for my app on the APP Platform. I am having a socket.io/node.js application and I need to pass an environment variable on my client-side:
let socket = io.connect('https://some-url.com', {
reconnection: false,
transports: ['websocket'],
upgrade: false
});
I need to add an environment variable to pass the URL upon the deployment of the app. I tried with ${APP_URL} and with process.env.APP_URL but neither of those seems to work.
Thanks in advance!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey all, I somehow managed to use a workaround and I’m sharing it here in case somebody faces the same problem. I used the following code:
let url = window.location.href;
const {hostname} = new URL(url);
let socket = io.connect(`https://${hostname}`, {
reconnection: false,
transports: ['websocket'],
upgrade: false
});
I am defining a variable to get the current URL, then I am using the URL constructor to extract the URL. I am then making a string with https://${hostname} to put the URL in use.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.