I was trying to implement Firebase authentication with Svelte Kit and did everything accordingly to this repository https://github.com/eraygundogmus/sveltekit-firebase-auth-example
Although it’s not working – when the login modal window is opened nothing is there, but a message saying that host 127.0.0.1 refusing connection on port 9099.
How it’s set up in firebase.json
{
"hosting": {
"source": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"emulators": {
"auth": {
"port": 9099
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
And firebase.client.ts
export let db: Firestore;
export let app: FirebaseApp;
export let auth: Auth;
const firebaseConfig = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
appId: import.meta.env. VITE_FIREBASE_APP_ID,
useEmulator: 'true',
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN
};
export const initializeFirebase = () => {
if (!browser) {
throw new Error("Can't use the Firebase client on the server.");
}
if (!app) {
app = initializeApp(firebaseConfig);
auth = getAuth(app);
if (firebaseConfig.useEmulator) {
connectAuthEmulator(auth, 'http://127.0.0.1:9099');
}
}
};
What is wrong here?