Google oauth Authorization URL
const handleGoogleLogin = () => { 67 | // Redirect to Google OAuth authorization URL
68 | fetch(
${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/auth/google/authorize) | ^ 69 | .then((response) => { 70 | if (!response.ok) { 71 | throw new Error('Failed to get authorization URL');
I get this error when i click Sign in with google.
How can i solve this?
Ive set up oauth on google console already
const handleGoogleLogin = () => { 67 | // Redirect to Google OAuth authorization URL
68 | fetch(
${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/auth/google/authorize) | ^ 69 | .then((response) => { 70 | if (!response.ok) { 71 | throw new Error('Failed to get authorization URL');I get this error when i click Sign in with google.
How can i solve this?
Ive set up oauth on google console already
Hey I need more info. With one glance looks like you are not running the backend or your env val is wrong. Send me more info on how to replicate this bug.
Hey. I just install surfsense following the documentation. Then i setup oauth in google console. Went back to the homepage and just click Sign it with google and theres a small popup that says 1 issue. Thats all
Make sure to enable people api in google oauth console and did you setup the .env files?
deploy.env right? and You mean the client id and secret key? yes i did, And yes i did enable google people API
Are you doing Docker Setup or Manual Setup? And make sure to set proper backend url in frontend .env file https://github.com/MODSetter/SurfSense/blob/main/surfsense_web/.env.example
Are you doing Docker Setup or Manual Setup? And make sure to set proper backend url in frontend .env file https://github.com/MODSetter/SurfSense/blob/main/surfsense_web/.env.example
Docker. Wait ... the backend url cannot be localhost:8000?
Does it matter if the url im accessing is actually http://192.168.31.7:3000/
Are you doing Docker Setup or Manual Setup? And make sure to set proper backend url in frontend .env file https://github.com/MODSetter/SurfSense/blob/main/surfsense_web/.env.example
Docker. Wait ... the backend url cannot be localhost:8000?
Honestly for me localhost:8000 works. Can you open localhost:8000/docs in webbrowser and lmk if anything opens.
Does it matter if the url im accessing is actually http://192.168.31.7:3000/
Should be fine.
I got the fastapi document. But i got to use 192.168.31.7:8000
Feel like some network issue. Can you use NEXT_PUBLIC_FASTAPI_BACKEND_URL=http://192.168.31.7:8000 in frontend .env https://github.com/MODSetter/SurfSense/blob/main/surfsense_web/.env.example
Oh yeah, i did that 15 minute ago. Got the Google OAuth page. But
device_id and device_name are required for private IP: http://192.168.31.7:8000/auth/google/callback Learn more about this error If you are a developer of SurfSense, see error details. Error 400: invalid_request
But on google oauth, im not allowed to use IP address as the callback url. And if i use cloudflare tunnel to mask 192.168.31.7:3000, i get the same original error. Can you guide me how to setup a domain so that it satisfies both the local url and google cloud console url?
Ive solved the url issue using ngrok. But after google authentication is successful - i get this error
Error: Failed to fetch
hooks/use-search-spaces.ts (22:34) @ useSearchSpaces.useEffect.fetchSearchSpaces
20 | try { 21 | setLoading(true);
22 | const response = await fetch(
${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/searchspaces, { | ^ 23 | headers: { 24 | Authorization:Bearer ${localStorage.getItem('surfsense_bearer_token')}, 25 | }, Call Stack 2
useSearchSpaces.useEffect.fetchSearchSpaces hooks/use-search-spaces.ts (22:34) useSearchSpaces.useEffect hooks/use-search-spaces.ts (45:7) Was this helpful?
1
https://surfsense.staywithg.com/dashboard << redirected to this url and then throw me that error.
Hey you cannot call HTTP endpoints over HTTPS. Your url is HTTPS so backend also needs to be running over HTTPS.
Hey you cannot call HTTP endpoints over HTTPS. Your url is HTTPS so backend also needs to be running over HTTPS.
So how can i make the backend HTTPS too? or any other way?
Hey you cannot call HTTP endpoints over HTTPS. Your url is HTTPS so backend also needs to be running over HTTPS.
So how can i make the backend HTTPS too? or any other way?
You need SSL Key & Cert for that : https://stackoverflow.com/questions/69207474/enable-https-using-uvicorn
Hi! This happened to me as well. A bit late, but since the issue is still open I'll share my case.
In my case, I run it behind a reverse-proxy so the TLS is handled by the proxy and the backend runs on HTTP. Some callbacks from the frontend doesn't have a trailing slash (e.g /api/v1/searchspaces). The requests will then be redirected by the backend to the endpoints with the trailing slash (e.g. /api/v1/searchspaces/). Since the backend does not forward the headers, it redirects to the HTTP rather than HTTPS which is problematic if your deployment is on HTTPS.
The solution is to enable header forwarding on the backend. In surfsense_backend/main.py
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Run the SurfSense application')
parser.add_argument('--reload', action='store_true', help='Enable hot reloading')
args = parser.parse_args()
uvicorn.run(
"app.app:app",
host="0.0.0.0",
log_level="info",
reload=args.reload,
reload_dirs=["app"],
# Add this line below
proxy_headers=True,
# Also add this line below. If you have a reverse proxy, this line should contain the address of the reverse proxy. If not, this allows redirection from any IP which may be dangerous
forwarded_allow_ips="0.0.0.0/0"
)
With this it essentially runs on proxy mode. Hope this helps!
Anyway, maybe it is better if we make it configurable via file or args?