aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-07-08 15:19:32 +1000
committerTerry Truong <terry06890@gmail.com>2022-07-08 15:21:01 +1000
commit347f5127929b17671c75734af5a374ec4f39b5ae (patch)
treebae9b7464ae06b0b18a0c9460ba1e48254d754e4
parent4e2830b6986aef2486d12c20ffc37d4bb595ced4 (diff)
Revert back to using vite-proxy for avoiding CORS issues
-rwxr-xr-xbackend/cgi-bin/data.py5
-rw-r--r--src/lib.ts2
-rw-r--r--vite.config.js3
3 files changed, 5 insertions, 5 deletions
diff --git a/backend/cgi-bin/data.py b/backend/cgi-bin/data.py
index b02cfc9..c1ea181 100755
--- a/backend/cgi-bin/data.py
+++ b/backend/cgi-bin/data.py
@@ -8,8 +8,7 @@ import gzip, jsonpickle
dbFile = "data/data.db"
DEFAULT_SUGG_LIM = 5
MAX_SUGG_LIM = 50
-CORS_ANY_ORIGIN = True # Used during development to avoid Cross-Origin Resource Sharing restrictions
-ROOT_NAME = 'cellular organisms'
+ROOT_NAME = "cellular organisms"
usageInfo = f"""
Usage: {sys.argv[0]}
@@ -230,8 +229,6 @@ def respondJson(val):
content = gzip.compress(content, compresslevel=5)
print(f"Content-length: {len(content)}")
print(f"Content-encoding: gzip")
- if CORS_ANY_ORIGIN:
- print("Access-Control-Allow-Origin: *")
print()
sys.stdout.flush()
sys.stdout.buffer.write(content)
diff --git a/src/lib.ts b/src/lib.ts
index faec861..d737879 100644
--- a/src/lib.ts
+++ b/src/lib.ts
@@ -7,7 +7,7 @@ import {LayoutOptions} from './layout';
import {getBreakpoint, Breakpoint, getScrollBarWidth, onTouchDevice} from './util';
// For server requests
-const SERVER_URL = 'http://localhost:8000/cgi-bin/data.py'
+const SERVER_URL = window.location.href + 'cgi-bin/data.py'
export async function queryServer(params: URLSearchParams){
// Construct URL
let url = new URL(SERVER_URL);
diff --git a/vite.config.js b/vite.config.js
index f1e7552..ebcdcd3 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -5,6 +5,9 @@ export default defineConfig({
base: '/',
plugins: [vue()],
server: {
+ proxy: {
+ '/cgi-bin/data.py': 'http://localhost:8000'
+ },
watch: {
ignored: ['**/backend', '**/public']
},