Skip to content
Snippets Groups Projects
Commit afbede2e authored by richard.petersen's avatar richard.petersen :sailboat:
Browse files

Fixup for fastify: Only consider the path when serving files, not url params

parent 2650861d
No related branches found
No related tags found
No related merge requests found
import fastify from 'fastify'
import formBodyPlugin from '@fastify/formbody'
import urlDataPlugin from '@fastify/url-data'
import fastifySwagger from '@fastify/swagger'
import fastifyMetrics from 'fastify-metrics'
import helmet from '@fastify/helmet'
......@@ -22,6 +23,7 @@ export async function createApp (basePath) {
connectionTimeout: 30000
})
await app.register(formBodyPlugin)
await app.register(urlDataPlugin)
await app.register(helmet, {
contentSecurityPolicy: false,
crossOriginEmbedderPolicy: false,
......
......@@ -6,7 +6,7 @@ export default async function serveFilePlugin (fastify, options) {
fastify.get('*', async (req, reply) => {
try {
const version = reply.version
const url = req.url.substr((options.prefix || '/').length - 1)
const url = req.urlData('path').substr((options.prefix || '/').length - 1)
const path = url === '/' ? '/index.html' : url
const { body, headers } = await getFile({ version, path })
......
......@@ -98,6 +98,14 @@
openapi-types "^11.0.0"
rfdc "^1.3.0"
"@fastify/url-data@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@fastify/url-data/-/url-data-5.1.0.tgz#1674b2f93ef877dde79db4f7ccc97eeff15c1d79"
integrity sha512-n8mz0FiXOOxFJP5QqoMTmfQ9Ejt56K+o+NzJVoDq6LWRZaA1cn0gfR8u0njuiliBTSgbrGovxz6oOQIOQfmW3w==
dependencies:
fastify-plugin "^4.0.0"
uri-js "^4.2.1"
"@humanwhocodes/config-array@^0.10.4":
version "0.10.4"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c"
......@@ -3319,7 +3327,7 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
uri-js@^4.2.2:
uri-js@^4.2.1, uri-js@^4.2.2:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment