Commit to stream via js-client

Hello izzy,

right now I’m stuck at getting an access token from Speckle that I need for GraphQL.

What I want to do is to get an access_token through a Javascript fetch request. I need to login to Speckle in the background and not through the auth page in the Speckle server. My Speckle server is running on my local machine through docker. The problem that I have right now is that I get a Cors-error when trying to fetch from “http://localhost:5002/auth/local/login?challenge=s88sbavs2ios4g3vmlimp” with my JS-Client saying " No ‘Access-Control-Allow-Origin’ header is present on the requested resource".

This is the code that I have copied from Postman because it works there:

		var myHeaders = new Headers();
		myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

		var urlencoded = new URLSearchParams();
		urlencoded.append("password", "examplePw");
		urlencoded.append("name", "exampleName");
		urlencoded.append("email", "example@examplemail.com");

		var requestOptions: any = {
			method: "POST",
			headers: myHeaders,
			body: urlencoded,
			redirect: "follow",
		};

		fetch("http://localhost:5002/auth/local/register?challenge=s88sbavs2ios4g3vmlimp", requestOptions)
			.then((response) => response.text())
			.then((result) => console.log(result))
			.catch((error) => console.log("error", error));
		return;

would appreciate some help here :slight_smile: