Skip to content

Commit

Permalink
Remove frontend proxying because we have CORS now
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Sep 29, 2020
1 parent e4ada4b commit db0254c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion tnoodle-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.1.0",
"private": true,
"homepage": "http://localhost:2014/scramble",
"proxy": "http://localhost:2014",
"dependencies": {
"bootstrap": "^4.4.1",
"fetch-intercept": "^2.3.1",
Expand Down
20 changes: 10 additions & 10 deletions tnoodle-ui/src/main/api/tnoodle.api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
let baseUrl = window.location.origin;
// let baseUrl = "http://localhost:2014";
let backendUrl = new URL(window.location.origin);
backendUrl.port = 2014;

export const tNoodleBackend = backendUrl.toString();

let zipEndpoint = "/wcif/zip";
let versionEndpoint = "/version";
Expand All @@ -20,9 +22,7 @@ export const fetchZip = (scrambleClient, wcif, mbld, password, translations) =>
payload.zipPassword = password;
}

let targetMarker = wcif.id;

return scrambleClient.loadScrambles(zipEndpoint, payload, targetMarker)
return scrambleClient.loadScrambles(zipEndpoint, payload, wcif.id)
.then((result) => convertToBlob(result))
.catch((error) => console.error(error));
};
Expand All @@ -35,13 +35,13 @@ const convertToBlob = async (result) => {
};

export const fetchWcaEvents = () => {
return fetch(baseUrl + wcaEventsEndpoint)
return fetch(tNoodleBackend + wcaEventsEndpoint)
.then((response) => response.json())
.catch((error) => console.error(error));
};

export const fetchFormats = () => {
return fetch(baseUrl + formatsEndpoint)
return fetch(tNoodleBackend + formatsEndpoint)
.then((response) => response.json())
.catch((error) => console.error(error));
};
Expand All @@ -59,13 +59,13 @@ export const fetchBestMbldAttempt = (wcif) => {
};

export const fetchRunningVersion = () => {
return fetch(baseUrl + versionEndpoint)
return fetch(tNoodleBackend + versionEndpoint)
.then((response) => response.json())
.catch((error) => console.error(error));
};

export const fetchAvailableFmcTranslations = () => {
return fetch(baseUrl + fmcTranslationsEndpoint)
return fetch(tNoodleBackend + fmcTranslationsEndpoint)
.then((response) => response.json())
.catch((error) => console.error(error));
};
Expand All @@ -86,7 +86,7 @@ const fmcTranslationsHelper = (translations) => {
};

const postToTnoodle = (endpoint, payload) =>
fetch(baseUrl + endpoint, {
fetch(tNoodleBackend + endpoint, {
method: "POST",
headers: {
Accept: "application/json",
Expand Down
7 changes: 6 additions & 1 deletion tnoodle-ui/src/main/api/tnoodle.socket.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { tNoodleBackend } from "./tnoodle.api";

export class ScrambleClient {
constructor(onHandshake, onProgress) {
this.onHandshake = onHandshake;
Expand Down Expand Up @@ -65,7 +67,10 @@ export class ScrambleClient {
}
}

const BASE_URL = window.location.origin.replace(/^https?:\/\//,'ws://');
let wsTNoodleBackend = new URL(tNoodleBackend);
wsTNoodleBackend.protocol = "ws:";

const BASE_URL = wsTNoodleBackend.toString();

const SCRAMBLING_STATES = {
IDLE: "IDLE",
Expand Down

0 comments on commit db0254c

Please sign in to comment.