env variables handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// pushFlicIntegration.js
|
||||
import { getPublicVapidKey, BACKEND_URL, FLIC_BUTTON_ID, FLIC_ACTIONS } from '../config.js';
|
||||
import { getPublicVapidKey, getBackendUrl, FLIC_BUTTON_ID} from '../config.js';
|
||||
|
||||
let pushSubscription = null; // Keep track locally if needed
|
||||
let actionHandlers = {}; // Store handlers for different Flic actions
|
||||
@@ -28,19 +28,6 @@ function getBasicAuthCredentials() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Prompt the user for credentials after permissions are granted
|
||||
function promptForCredentials() {
|
||||
console.log('Prompting user for auth credentials.');
|
||||
const username = prompt('Please enter your username for backend authentication:');
|
||||
if (!username) return null;
|
||||
const password = prompt('Please enter your password:');
|
||||
if (!password) return null;
|
||||
|
||||
const credentials = { username, password };
|
||||
localStorage.setItem('basicAuthCredentials', JSON.stringify(credentials));
|
||||
return credentials;
|
||||
}
|
||||
|
||||
// Create Basic Auth header string
|
||||
function createBasicAuthHeader(credentials) {
|
||||
if (!credentials?.username || !credentials.password) return null;
|
||||
@@ -167,7 +154,9 @@ async function sendSubscriptionToServer(subscription, buttonId) {
|
||||
|
||||
try {
|
||||
// Add support for handling CORS preflight with credentials
|
||||
const response = await fetch(`${BACKEND_URL}/subscribe`, {
|
||||
console.log("BACKEND_URL Key: " + getBackendUrl());
|
||||
console.log("FLIC_BUTTON_ID Key: " + FLIC_BUTTON_ID);
|
||||
const response = await fetch(`${getBackendUrl()}/subscribe`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ button_id: buttonId, subscription: subscription }),
|
||||
headers: headers,
|
||||
|
||||
Reference in New Issue
Block a user