Set BITBUCKET_* variables for use inside an Electron Angular app

116 views Asked by At

I have an Angular/Electron app running, which I want to auto-update itself. I have electron-builder working, it uploads the build files (<name>.exe, <name>.blockmap and latest.yml) without issue. But when I run the app on my Windows machine, electron-updater returns a 404 on the "latest.yml" file.

I've rested it directly with cURL and it works fine.

curl -L -H "Authorization: Basic <token>" https://api.bitbucket.org/2.0/repositories/<owner>/<repo>/downloads/latest.yml

The only different I can see is the -L switch which makes cURL follow redirects. Is this handled by electron-updater? Does it require some specific config for this to work properly?

Or maybe I'm doing the build wrong... I have the 2 BITBUCKET_* variables set on my build command. Should I expect the values to be built into the app? If not, what would be the best way to have those values set in the app without hardcoding them in the code?

Thanks!

UPDATE 1: I tried to put those variables in a .env file and include it in the build files list but it doesn't seem to be read when the app is run on the Windows machine.

UPDATE 2: I compiled the app as a Linux AppImage, then ran it from the command line while also setting the env variables in the command: BITBUCKET_USERNAME=<user> BITBUCKET_TOKEN=<app-password> ./<name>.AppImage but I'm also getting a 404 on the version update check. I see the variables as set if I log process.env to the console.

UPDATE 3: I even hardcoded the values in the entry script like so on the very first line, before require statements:

process.env.BITBUCKET_USERNAME = '<user>';
process.env.BITBUCKET_TOKEN = '<app-password>';

and still getting a 404.

SOLVED: Issue was an extra colon in the auth header. Basic: <token> should've been Basic <token>.

0

There are 0 answers