in my website Signup page, i'm using firebase auth for web ( @angular/fire version for angular websites ) to signup a user using Google Signup, i'm doing this using the SignInWithPopup function.
this is my AuthService class :
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(
private afAuth: AngularFireAuth,
private http: HttpClient
) {}
private readonly api_url: string = environment.apiUrl
async googleAuth() {
return await this.afAuth.signInWithPopup(new GoogleAuthProvider())
}
etc ...
and using it like this in signup.component.ts :
googleUserSubmitted() {
this.loadingGoogleUser = true
this.signupWithGoogle()
.then((res) => {
res.user?.getIdToken()
.then((token) => {
this.googleForm.patchValue({
email: res.user?.email,
name: res.user?.displayName,
tokenID: token
})
})
.finally(() => {
this.loadingGoogleUser = false
})
})
.catch(() => {
this.loadingGoogleUser = false
})
}
this function works normally on my laptop when using chrome or firefox browser . but the problem when i try to signup form my android device, I've inspected the console using USB debugging to see what errors I'm getting when doing so. and I saw the following :
Access to XMLHttpRequest at 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=MY_API_KEY_HERE' from origin 'https://sakostore-bd7ad.firebaseapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
what I tried to solve this problem and sadly not working :
some context to help you understand the problem :
I Found The Solution Finally .
i forgot to try to connect to a VPN.
while living in syria there are some restrictions when connecting the website with the firebase web app instance.
my mobile devices was not connected to any vpn . so GoolgeAuthProvider()
neither any firebase service was not working .
it appeared to be a region problem