-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: reduce middleware syntax error logs, send to logs, tests for CSP in each env #213
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -149,7 +152,7 @@ export async function authMiddleware( | |||
return response; | |||
} | |||
} catch (error) { | |||
console.error("Error in authMiddleware", error); | |||
console.error({ event: "middleware.auth.error", error }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we log JSON then Datadog is able to query it
Playwright e2e testsTo view traces locally, unzip the report and run: npx playwright show-report ~/Downloads/playwright-report |
…tested. Add tests
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 }); | ||
} | ||
|
||
const cspConfig: CspConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to a config allows us to test the CSP generation without relying on ENV being set.
const sentryEnv = process.env.NEXT_PUBLIC_SENTRY_ENV; | ||
const sentryRelease = process.env.NEXT_PUBLIC_APP_VERSION; | ||
const sentryReportUri = `${process.env.SENTRY_REPORT_URI}&sentry_environment=${sentryEnv}&sentry_release=${sentryRelease}`; | ||
function generateNonce(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too happy about this. Because it's an edge function, and we're running the test in node we need a way to generate the nonce in both environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are snapshots so that we can review if there are any changes to how the CSP is generated
@@ -0,0 +1,14 @@ | |||
default-src 'self' | |||
media-src 'self' 'self' https://*.mux.com https://stream.mux.com blob: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codeincontext is this a bug? Should there be as string after blob:?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const savedPolicies = readPoliciesFromFile(env); | ||
expect(generatedPolicies).toBe(savedPolicies); | ||
} | ||
expect(generatedPolicies).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So nice!
Quality Gate passedIssues Measures |
🎉 This PR is included in version 1.10.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description