Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"window.reese84 is undefined" when logging in #13

Open
Arcegis opened this issue Jun 2, 2023 · 13 comments
Open

"window.reese84 is undefined" when logging in #13

Arcegis opened this issue Jun 2, 2023 · 13 comments

Comments

@Arcegis
Copy link

Arcegis commented Jun 2, 2023

I'm using latest exec.

As soon as I enter email and password, a message pops in red "window.reese84 is undefined". See hereby screenshot, and Console logs.

Uncaught (in promise) TypeError: window.reese84 is undefined
authenticate index.js:117
w vuex.esm.js:851
dispatch vuex.esm.js:516
dispatch vuex.esm.js:406
submit Login.vue:90
submit Login.vue:1
VueJS 3
https://pixheb.ovh/images/a4a40a8a21bd2cf08a185fc1e1122f8d.png

@Arcegis
Copy link
Author

Arcegis commented Jun 2, 2023

Adding a message to notice that https://f1tokenx.deta.dev/ displays now "Service No Longer Available"

@iebb
Copy link
Owner

iebb commented Jun 3, 2023

yep, deta is now down. i'm considering deploying elsewhere

@christovic
Copy link

christovic commented Jun 3, 2023

Is this a component that we could also self-host? Is the source code for what used to be running on deta publicly available?

Essentially, I guess what I'm asking is, is there a way for us to host everything on our own servers so we don't have to rely on third-party services?

@s0fax
Copy link

s0fax commented Jun 3, 2023

Maybe config file to place the token in or a token login field.
Token can be extracted here > https://github.com/SoMuchForSubtlety/f1viewer/wiki/Getting-your-subscription-token

@christovic
Copy link

At a second glance, it looks like that deta instance was proxying requests to https://api.formula1.com/6657193977244c13...

@iebb
Copy link
Owner

iebb commented Jun 4, 2023

Is this a component that we could also self-host? Is the source code for what used to be running on deta publicly available?

Essentially, I guess what I'm asking is, is there a way for us to host everything on our own servers so we don't have to rely on third-party services?

Yep, that's planned, but I'm pretty busy previously but the all-in-one thing should work before next GP

@christovic
Copy link

Music to my ears, thanks mate.

I have hacked together something and it's working for today.

If it's of any help to anyone else, this is what I have running on a domain from freedns to rewrite the URL and a couple of headers.

from flask import Flask, request
from flask_cors import CORS
import requests
import logging
import sys

app = Flask(__name__)
CORS(app)

API_HOST="https://api.formula1.com/6657193977244c13?d=account.formula1.com"

@app.route('/6657193977244c13', methods=["GET"])
def getjs():
    return requests.get("https://api.formula1.com/6657193977244c13").text

@app.route('/6657193977244c13', methods=["POST"])
def rewrite():
    app.logger.debug(request.headers)
    headers = {k:v for k,v in request.headers if k.lower() != 'host'}
    headers['Origin'] = "https://account.formula1.com"
    headers['Referer'] = "https://account.formula1.com/"
    res = requests.request(
        method          = "POST",
        url             = API_HOST,
        headers         = headers,
        data            = request.get_data(),
        cookies         = request.cookies,
        allow_redirects = False,
    )
    return res.text, res.status_code

if __name__ == "__main__":
    app.run()

I'm sure it's doable in express & node-fetch but I couldn't get the raw data from a request in time for the GP today so I just did it in python Flask which I'm much more comfortable with!

@iebb
Copy link
Owner

iebb commented Jun 4, 2023

for quick fix:
just built a version which is using api endpoint deployed at vercel.

https://github.com/iebb/F1WebViewer-SelfHosted/releases/tag/v0.2.1

check this, it should work

@Arcegis @christovic @s0fax @FelixSFD

@christovic
Copy link

Niiiiiice thanks @iebb ! I will deploy that after this GP and report back 🤞

@s0fax
Copy link

s0fax commented Jun 4, 2023

@iebb thank you works, so i can run it on LG webos Browser :)

@Arcegis
Copy link
Author

Arcegis commented Oct 18, 2024

Hello, I can confirm that, as of today, the message pops up once again.
Beside, f1-api.jeb.nom.za gives a NS_ERROR_UNKNOWN_HOST response. I suppose that the API you use is now EoL...

@s0fax
Copy link

s0fax commented Oct 18, 2024

christovic's Script above works, when you self host the F1-Web-Viewer and the Script.
I have now configured both into an alpine container, hung caddy with ssl cert in front, then I was able to sign in and watch warm-up show.

Python and the modules flask, flask_cors and requests are required to run the script.
Flask defaults on localhost:5000, so I have adapted the last line in the script
app.run(host='0.0.0.0', port=5000)

The following variable is required to build F1-Web-Viewer with current nodejs
export NODE_OPTIONS=--openssl-legacy-provider
and the Public/index.html must be adjusted in line 13 with your domain.

@christovic
Copy link

I ended up writing my own F1 viewer that handles the login process a bit smoother than this one, but it's not as feature rich. Super simple static page - it's a bit lighter on resources and just automatically loads and plays the live GP if there is one.

In this, I ended up writing a reese84 handler in golang, dropping here too if it is useful for anyone else:

func reeseHandler(w http.ResponseWriter, r *http.Request) {
	if r.Method == "GET" {
		resp, err := http.Get("https://api.formula1.com/6657193977244c13")
		if err != nil {
			upstreamF1TVApiError(err, w)
			return
		}
		body, err := io.ReadAll(resp.Body)
		if err != nil {
			upstreamF1TVApiError(err, w)
			return
		}
		w.Write(body)
	} else if r.Method == "POST" {
		proxyReq, err := http.NewRequest(r.Method, "https://api.formula1.com/6657193977244c13?d=account.formula1.com", r.Body)

		if err != nil {
			http.Error(w, "Error creating proxy request", http.StatusInternalServerError)
			return
		}

		for name, values := range r.Header {
			for _, value := range values {
				proxyReq.Header.Add(name, value)
			}
		}
		proxyReq.Header.Add("Origin", "https://account.formula1.com")
		proxyReq.Header.Add("Referer", "https://account.formula1.com")
		resp, err := http.DefaultClient.Do(proxyReq)

		if err != nil {
			upstreamF1TVApiError(err, w)
			return
		}

		upstreamBody, err := io.ReadAll(resp.Body)

		if err != nil {
			upstreamF1TVApiError(err, w)
			return
		}

		w.Write(upstreamBody)
	}
}

func upstreamF1TVApiError(err error, w http.ResponseWriter) {
	log.Println(err)
	http.Error(w, "Error from api.formula1.com", http.StatusBadGateway)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants