Code runs in test, fails on deploy

My Code is running perfectly fine in the test environment, but fails if I try to deploy

here is the log of the errors

Here is the code that is supposedly throwing the exception

export class Database {

	static async get(key) {
		return await fetch(FIREBASE_URL + encodeURIComponent(key) + "/.json?auth=" + FIREBASE_SECRET)
			.then(e => e.text())
			.then(value => {
				if (!value) return null;
				try { value = JSON.parse(value); }
				catch { return null; }
				if (value === undefined || value === null || value.error !== undefined) return null;
				return value;
			});
	}

	static async set(key, value) {
		await fetch(FIREBASE_URL + encodeURIComponent(key) + "/.json?auth=" + FIREBASE_SECRET, {
			method: "PUT",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify(value),
		});
	}

	static async delete(key) {
		await fetch(
			FIREBASE_URL + encodeURIComponent(key) + "/.json?auth=" + FIREBASE_SECRET,
			{ method: "DELETE" }
		);
	}

	static async dictionary() {
		return await fetch(`${FIREBASE_URL}/.json?auth=${FIREBASE_SECRET}`)
			.then(e => e.text())
			.then(value => {
				if (!value) return null;
				try { value = JSON.parse(value); }
				catch { return null; }
				if (value === undefined || value === null || value.error !== undefined) return null;
				return value;
			});
	}

}

the code works perfectly in test but the second i attempt to deploy it it fails. Any tips?

I would have to see your Repl to be sure but it looks like the FIREBASE_SECRET environment variable is not correctly set. It’s not enough to set it in the secrets pane, you also have to set it in the deployments pane as well.

3 Likes

you should get a raise <3

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.