UMB-CS-682-Team-03 / tracker

0 stars 0 forks source link

Translation endpoint is missing trailing / #79

Closed rouilj closed 5 months ago

rouilj commented 5 months ago

Roundup requires the trailing / on the base url. So http://localhost:8080/demo/?@template... works. http://localhost:8080/demo?@template... gets a 301 redirect when I run locally.

However when I run in production behind a proxy server, I get a 404 and html response. This causes classhelper to error because it can't resolve the html as json. Not sure why I get a redirect in once case and a 404 in the other.

It's an easy fix though:

diff --git a/html/classhelper.js b/html/classhelper.js
index 3ff630ef..688b5692 100644
--- a/html/classhelper.js
+++ b/html/classhelper.js
@@ -305,7 +311,7 @@ class ClassHelper extends HTMLElement {
         }

         let tracker = window.location.pathname.split('/')[1];
-        let url = new URL(window.location.origin + "/" + tracker);
+        let url = new URL(window.location.origin + "/" + tracker + '/');
         url.searchParams.append("@template", "translation");
         url.searchParams.append("properties", Array.from(keys.values()).join(','));