From b877fa83c48ff9a1e1ee15b02a7991f77f96ebb2 Mon Sep 17 00:00:00 2001 From: Hiromu OCHIAI Date: Fri, 15 Nov 2024 20:41:02 +0900 Subject: [PATCH] Fix API --- next.config.js | 2 ++ package.json | 12 +++++++----- server/filters/auth.go | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/next.config.js b/next.config.js index 2bff9bd..724956e 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,8 @@ module.exports = (phase, { defaultConfig }) => { * @type {import('next').NextConfig} */ const nextConfig = { + output: process.env.NODE_ENV == "production" ? "export" : undefined, + distDir: "dest", images: { loader: 'custom', domains: [ diff --git a/package.json b/package.json index 053e88a..50071fa 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,16 @@ "name": "hub", "version": "1.0.1", "engines": { - "node": "20.15.1", - "npm": "10.7.0" + "node": "20", + "pnpm": "9" }, "description": "", "main": "index.js", "scripts": { - "test": "jest", + "test": "vitest", "dev": "next dev ./client", "build": "next build ./client", - "export": "NODE_ENV=production next build ./client && next export ./client -o ./client/dest", + "export": "NODE_ENV=production next build ./client", "lint": "next lint ./client" }, "repository": { @@ -42,7 +42,9 @@ "react-test-renderer": "^18.3.1", "sass": "^1.38.0", "tailwindcss": "^3.0.15", - "typescript": "^4.3.5" + "too": "^3.0.1", + "typescript": "^4.3.5", + "vitest": "^2.1.5" }, "dependencies": { "@headlessui/react": "^1.4.0", diff --git a/server/filters/auth.go b/server/filters/auth.go index d58cc5e..18353fc 100644 --- a/server/filters/auth.go +++ b/server/filters/auth.go @@ -51,9 +51,11 @@ func (auth *Auth) Handle(next http.Handler) http.Handler { if err != nil { panic(err) } + defer f.Close() myself := models.Myself{} - json.NewDecoder(f).Decode(&myself) - f.Close() + if err = json.NewDecoder(f).Decode(&myself); err != nil { + panic(err) + } next.ServeHTTP(w, SetSessionUserContext(req, myself.OpenID.Sub)) return }