-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vercel deployment bug caused by per-route security config #538
Comments
Hey Buddy, Thanks for the description and reproduction. I do think as well that it is a Vercel specific thing. Your reproduction contains several examples of route Rules, have you tried decreasing the number of these rules to one simple one like headers.xXxsProtection = '1' and see if it will fail then as well? I may find some time next week to look at it but if you will be faster I would try that to see if it is actually about the headers. Maybe it is related to other middleware functions that are set for certain route (like rate limiter) instead of headers and we don't know that because the repro repository contains several examples. |
@Baroshem Greetings! I tried so many options, and it seems the So, yes, it seems that is a specific Vercel thing of |
I also want to note that defining // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: ['nuxt-security'],
compatibilityDate: '2024-04-03',
devtools: { enabled: true },
router: {
options: {
strict: true,
},
},
routeRules: {
'/': {
security: {
// headers: {
// contentSecurityPolicy: {
// 'frame-ancestors': [
// "'self'",
// ],
// },
// },
corsHandler: {
origin: [
process.env.NUXT_PUBLIC_APP_BASE_URL as string,
],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
},
'/test': {
security: {
// headers: {
// contentSecurityPolicy: {
// 'frame-ancestors': [
// "'self'",
// ],
// },
// },
corsHandler: {
origin: [
process.env.NUXT_PUBLIC_APP_BASE_URL as string,
],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
},
'/custom': {
security: {
// headers: {
// contentSecurityPolicy: {
// 'frame-ancestors': [
// "'self'",
// 'https://example.com',
// 'https://www.example.com',
// ],
// },
// },
corsHandler: {
origin: [
process.env.NUXT_PUBLIC_APP_BASE_URL as string,
'https://example.com',
'https://www.example.com',
],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
},
'/api/statistics/custom': {
security: {
corsHandler: {
origin: ['https://example.com', 'https://www.example.com'],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
},
'/api/statistics/entries': {
security: {
corsHandler: {
origin: [process.env.NUXT_PUBLIC_APP_BASE_URL as string],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
},
},
security: {
headers: {
contentSecurityPolicy: {
'img-src': [
"'self'",
'data:',
'https://example.com',
],
},
crossOriginEmbedderPolicy:
process.env.NODE_ENV === 'development' ? 'unsafe-none' : 'unsafe-none',
},
corsHandler: {
origin: [process.env.NUXT_PUBLIC_APP_BASE_URL as string],
},
rateLimiter: {
tokensPerInterval: 8,
interval: 10000,
},
},
}) |
Hmm interesting @vejja do you have any ideas why it could work like that? |
@maxdzin : |
@vejja Ah, sorry. I tried the successful config and forgot to revert it to the one that failed. |
Something tells me that there could be a problem with the |
You're right. This was exactly the case. |
@vejja there's an interesting thing... Also, I looked at the module plugins, in particular, As for PR #539, I'm not sure how to test that PR's changes exactly, so maybe you can share some advice regarding it. And, thank you for your help and quick response! |
Adding any random value into the per-route config, e.g. As for testing, ideally you would clone from source and build the module locally, then replace it into the |
Thank you, @vejja |
@vejja I tested the PR fix and it seems works well - the headers specified are passed correctly. |
Hello!
I have a Nuxt project with per-route security config. By deploying it to Vercel it fails with this error:
Local build works without errors, and it seems related to some Vercel-specific things.
I tried to dig in, but it is not yet clear to me why is that happening.
The problem relies on using the
routeRules
security configuration. When I define just some global config of this security module, everything works fine. But when I tried to define it per-route level, Vercel deployment failed with the error noted above. From this discussion I understand that it is due to some headers problem, but I'm not sure how the nuxt-security module should be configured properly by that.Version
nuxt-security: v2.0.0
nuxt: v3.13.2
Reproduction Link
https://github.com/maxdzin/nuxt-security-config-test
Steps to reproduce
What is Expected?
The Vercel deployment went without any errors and works properly.
What is actually happening?
By deploying on Vercel the minimal Nuxt + nuxt-security project with per-route security config it fails with this error:
The text was updated successfully, but these errors were encountered: