-
Notifications
You must be signed in to change notification settings - Fork 0
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
Lighthouse best practices & accessibility #131
Open
Tschonti
wants to merge
8
commits into
main
Choose a base branch
from
feature/f-161-lighthouse-best-practices-score
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1137b38
feat: some best practices and security fixes
Tschonti 51d5d66
feat: remove warnings, accessibility
Tschonti af8674b
fix: remove hc a11y
Tschonti 5561389
feat: readd hc a11y correctly
Tschonti e046ea2
feat: more labels
Tschonti b40e79d
fix: remove duplicate stuff
Tschonti eda5bf4
Merge branch 'main' into feature/f-161-lighthouse-best-practices-score
Tschonti be07d23
fix: add new cdn to CSP whitelist
Tschonti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export function middleware(request: NextRequest) { | ||
const nonce = Buffer.from(crypto.randomUUID()).toString('base64'); | ||
const cspHeader = ` | ||
default-src 'self'; | ||
script-src 'self' 'nonce-${nonce}' 'sha256-q1+DaXsZUnEJs3jpN9ZoWp6ypK1xBwXiRxG+C31xOUA=' 'strict-dynamic' 'unsafe-eval' 'unsafe-inline' ${process.env.NEXT_PUBLIC_API_URL?.slice(0, -3)}; | ||
style-src 'self' 'unsafe-inline'; | ||
connect-src 'self' https://region1.google-analytics.com ${process.env.NEXT_PUBLIC_API_URL?.slice(0, -3)} ${process.env.NEXT_PUBLIC_V3_API_URL?.slice(0, -3)} ${process.env.NEXT_PUBLIC_CHATBOT_API_URL ?? ''}; | ||
img-src 'self' blob: data: https://static.hungermapdata.org https://dev.api.earthobservation.vam.wfp.org; | ||
font-src 'self'; | ||
object-src 'none'; | ||
base-uri 'self'; | ||
form-action 'self'; | ||
frame-ancestors 'none'; | ||
upgrade-insecure-requests; | ||
`; | ||
// Replace newline characters and spaces | ||
const contentSecurityPolicyHeaderValue = cspHeader.replace(/\s{2,}/g, ' ').trim(); | ||
|
||
const requestHeaders = new Headers(request.headers); | ||
requestHeaders.set('x-nonce', nonce); | ||
|
||
requestHeaders.set('Content-Security-Policy', contentSecurityPolicyHeaderValue); | ||
|
||
const response = NextResponse.next({ | ||
request: { | ||
headers: requestHeaders, | ||
}, | ||
}); | ||
response.headers.set('Content-Security-Policy', contentSecurityPolicyHeaderValue); | ||
return response; | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
/* | ||
* Match all request paths except for the ones starting with: | ||
* - api (API routes) | ||
* - _next/static (static files) | ||
* - _next/image (image optimization files) | ||
* - favicon.ico (favicon file) | ||
*/ | ||
{ | ||
source: '/((?!api|_next/static|_next/image|favicon.ico).*)', | ||
missing: [ | ||
{ type: 'header', key: 'next-router-prefetch' }, | ||
{ type: 'header', key: 'purpose', value: 'prefetch' }, | ||
], | ||
}, | ||
], | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove this please