I'm trying to login with google on my svelte app, by sending a request to an express server, but on Firefox I'm getting a Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:8080/login. (Reason: CORS request did not succeed). Status code: (null).
error and on Chrome I get GET https://localhost:8080/login net::ERR_SSL_PROTOCOL_ERROR
,
this is my code on express :
"use strict";
import express from "express";
import cors from 'cors';
import { getAllForms } from "./services/get_form";
import { googleLogin } from "./services/auth";
const app = express();
app.use(cors({
origin: 'https://localhost:3000',
}))
app.get("/login", (req, res) => {
const auth = googleLogin();
res.send(auth);
})
app.listen(8080)
and frontend :
<script>
import HomeDialog from '../components/dialog/HomeDialog.svelte';
const login = async () => {
await fetch('https://localhost:8080/login').then((response) => {
console.log('response', response);
});
};
</script>
<svelte:head>
<title>Jamboit - Create a Game</title>
</svelte:head>
<HomeDialog
>Create a new Game
<button on:click={login}> Log in </button>
</HomeDialog>
any tips on how to make this work?