website: enable cors, allow requests to gaufre.js from any site

This commit is contained in:
Emmanuel Pelletier
2024-05-13 14:38:16 +02:00
parent 0593bbad15
commit eff5d0037e
3 changed files with 27 additions and 0 deletions

View File

@@ -13,6 +13,7 @@
"@astrojs/markdown-remark": "^5.1.0", "@astrojs/markdown-remark": "^5.1.0",
"@astrojs/react": "^3.3.1", "@astrojs/react": "^3.3.1",
"@astrojs/starlight": "^0.21.5", "@astrojs/starlight": "^0.21.5",
"@fastify/cors": "^9.0.1",
"@fastify/static": "^7.0.3", "@fastify/static": "^7.0.3",
"@gouvfr-lasuite/integration": "^0.1.3", "@gouvfr-lasuite/integration": "^0.1.3",
"@types/prismjs": "^1.26.3", "@types/prismjs": "^1.26.3",
@@ -1421,6 +1422,15 @@
"fast-uri": "^2.0.0" "fast-uri": "^2.0.0"
} }
}, },
"node_modules/@fastify/cors": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/@fastify/cors/-/cors-9.0.1.tgz",
"integrity": "sha512-YY9Ho3ovI+QHIL2hW+9X4XqQjXLjJqsU+sMV/xFsxZkE8p3GNnYVFpoOxF7SsP5ZL76gwvbo3V9L+FIekBGU4Q==",
"dependencies": {
"fastify-plugin": "^4.0.0",
"mnemonist": "0.39.6"
}
},
"node_modules/@fastify/error": { "node_modules/@fastify/error": {
"version": "3.4.1", "version": "3.4.1",
"resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz",
@@ -6525,6 +6535,14 @@
"node": ">=16 || 14 >=14.17" "node": ">=16 || 14 >=14.17"
} }
}, },
"node_modules/mnemonist": {
"version": "0.39.6",
"resolved": "https://registry.npmjs.org/mnemonist/-/mnemonist-0.39.6.tgz",
"integrity": "sha512-A/0v5Z59y63US00cRSLiloEIw3t5G+MiKz4BhX21FI+YBJXBOGW0ohFxTxO08dsOYlzxo87T7vGfZKYp2bcAWA==",
"dependencies": {
"obliterator": "^2.0.1"
}
},
"node_modules/mrmime": { "node_modules/mrmime": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz",
@@ -6626,6 +6644,11 @@
"url": "https://github.com/fb55/nth-check?sponsor=1" "url": "https://github.com/fb55/nth-check?sponsor=1"
} }
}, },
"node_modules/obliterator": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/obliterator/-/obliterator-2.0.4.tgz",
"integrity": "sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ=="
},
"node_modules/on-exit-leak-free": { "node_modules/on-exit-leak-free": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",

View File

@@ -18,6 +18,7 @@
"@astrojs/markdown-remark": "^5.1.0", "@astrojs/markdown-remark": "^5.1.0",
"@astrojs/react": "^3.3.1", "@astrojs/react": "^3.3.1",
"@astrojs/starlight": "^0.21.5", "@astrojs/starlight": "^0.21.5",
"@fastify/cors": "^9.0.1",
"@fastify/static": "^7.0.3", "@fastify/static": "^7.0.3",
"@gouvfr-lasuite/integration": "^0.1.3", "@gouvfr-lasuite/integration": "^0.1.3",
"@types/prismjs": "^1.26.3", "@types/prismjs": "^1.26.3",

View File

@@ -1,11 +1,14 @@
import { join } from "path" import { join } from "path"
import Fastify from "fastify" import Fastify from "fastify"
import fsfStatic from "@fastify/static" import fsfStatic from "@fastify/static"
import fsfCors from "@fastify/cors"
const fastify = Fastify({ const fastify = Fastify({
logger: true, logger: true,
}) })
fastify.register(fsfCors)
fastify.register(fsfStatic, { fastify.register(fsfStatic, {
root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"), root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"),
preCompressed: true, preCompressed: true,