-
Notifications
You must be signed in to change notification settings - Fork 962
Closed
Description
[REQUIRED] Describe your environment
- Operating System version: IOS 14
- Browser version: Capacitor 3
- Firebase SDK version: json api
- Firebase Product: auth
[REQUIRED] Describe the problem
Since I wasn't able to use auth sdk in capacitor i tried to do it by json API using :
https://github.com/samuelgozi/firebase-auth-lite/blob/d4ed969c9d7a9181910b14f05a6e1140b33448d0/src/main.js#L118
This work perfectly on web but not in Mobile app because of the capacitor origin .
[Error] Failed to load resource: Origin capacitor://localhost is not allowed by Access-Control-Allow-Origin. (token, line 0)
https://securetoken.googleapis.com/v1/token?key=****
Steps to reproduce:
Create a starter capacitor app with the code below
Relevant Code:
const signUp = () => {
const apiKey ="***"
const url = `https://securetoken.googleapis.com/v1/token?key=${apiKey}`;
return fetch(url, {
method: 'POST',
body: JSON.stringify({returnSecureToken: true})
}).then(async response => {
let data = await response.json();
// If the response returned an error, try to get a Firebase error code/message.
// Sometimes the error codes are joined with an explanation, we don't need that(its a bug).
// So we remove the unnecessary part.
if (!response.ok) {
const code = data.error.message.replace(/ ?: [\w ,.'"()]+$/, '');
throw Error(code);
}
return data;
});
}
signUp()
m8xp0w3r and Seanitzel