From 718a9b5da687247f228d28893b3be9963941a056 Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Sat, 28 Sep 2024 13:56:14 +0200 Subject: [PATCH] Add SSL support --- astro.config.mjs | 9 ++++++++- package-lock.json | 15 ++++++++++++++- package.json | 1 + src/lib/utils/langDriver.ts | 2 +- src/pages/login.astro | 2 +- src/pages/register.astro | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 28d38b8..d458dc5 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,5 +1,6 @@ import { defineConfig } from 'astro/config'; import icon from "astro-icon"; +import basicSsl from "@vitejs/plugin-basic-ssl"; import node from "@astrojs/node"; @@ -9,5 +10,11 @@ export default defineConfig({ integrations: [icon()], adapter: node({ mode: "standalone" - }) + }), + vite: { + plugins: [basicSsl()], + server: { + https: true + } + } }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 24596b1..6114eb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "AstroColony", + "name": "AstroCol", "version": "0.0.1", "lockfileVersion": 3, "requires": true, @@ -16,6 +16,7 @@ }, "devDependencies": { "@types/jest": "^29.5.12", + "@vitejs/plugin-basic-ssl": "^1.1.0", "dotenv": "^16.4.5", "jest": "^29.7.0", "ts-jest": "^29.1.4", @@ -2489,6 +2490,18 @@ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, + "node_modules/@vitejs/plugin-basic-ssl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.1.0.tgz", + "integrity": "sha512-wO4Dk/rm8u7RNhOf95ZzcEmC9rYOncYgvq4z3duaJrCgjN8BxAnDVyndanfcJZ0O6XZzHz6Q0hTimxTg8Y9g/A==", + "dev": true, + "engines": { + "node": ">=14.6.0" + }, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" + } + }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", diff --git a/package.json b/package.json index 69c77cf..8d2c79b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "devDependencies": { "@types/jest": "^29.5.12", + "@vitejs/plugin-basic-ssl": "^1.1.0", "dotenv": "^16.4.5", "jest": "^29.7.0", "ts-jest": "^29.1.4", diff --git a/src/lib/utils/langDriver.ts b/src/lib/utils/langDriver.ts index 82b0d4c..c5a916c 100644 --- a/src/lib/utils/langDriver.ts +++ b/src/lib/utils/langDriver.ts @@ -40,7 +40,7 @@ export async function getLocales(language: string) { return null; } - const lang = await (await fetch(`http://localhost:4321/api/lang/${language}.json`)).json(); + const lang = await (await fetch(`https://localhost:4321/api/lang/${language}.json`)).json(); return lang.data; } diff --git a/src/pages/login.astro b/src/pages/login.astro index 59d8b93..fb7947c 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -33,7 +33,7 @@ if(Astro.request.method === "POST") { if(!user) throw new Error("User not found"); const sessionTime = config.SESSION_TIME_MINUTES * 60; - const res = await fetch(`http://localhost:4321/api/auth/generateAccessToken`, { + const res = await fetch(`https://localhost:4321/api/auth/generateAccessToken`, { method: 'POST', body: JSON.stringify({ username, diff --git a/src/pages/register.astro b/src/pages/register.astro index 8b0a094..15f3a0b 100644 --- a/src/pages/register.astro +++ b/src/pages/register.astro @@ -60,7 +60,7 @@ if(Astro.request.method === "POST") { const sessionTime = config.SESSION_TIME_MINUTES * 60; - const res = await fetch(`http://localhost:4321/api/auth/generateAccessToken`, { + const res = await fetch(`https://localhost:4321/api/auth/generateAccessToken`, { method: 'POST', body: JSON.stringify({ username,