Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ yarn-error.log*
/playwright/envs.js
/playwright/affected-tests.txt

**.dec**
**.dec**
.idea
6 changes: 3 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';

import generateCspPolicy from 'nextjs/csp/generateCspPolicy';
// import generateCspPolicy from 'nextjs/csp/generateCspPolicy';
import * as middlewares from 'nextjs/middlewares/index';

const cspPolicy = generateCspPolicy();
// const cspPolicy = generateCspPolicy();

export function middleware(req: NextRequest) {
const isPageRequest = req.headers.get('accept')?.includes('text/html');
Expand All @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) {

const end = Date.now();
const res = NextResponse.next();
res.headers.append('Content-Security-Policy', cspPolicy);
// res.headers.append('Content-Security-Policy', cspPolicy);
res.headers.append('Server-Timing', `middleware;dur=${ end - start }`);
res.headers.append('Docker-ID', process.env.HOSTNAME || '');

Expand Down
1 change: 1 addition & 0 deletions nextjs/csp/generateCspPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function generateCspPolicy() {
descriptors.safe(),
descriptors.sentry(),
descriptors.walletConnect(),
descriptors.vercel(),
);

return makePolicyString(policyDescriptor);
Expand Down
1 change: 1 addition & 0 deletions nextjs/csp/policies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { monaco } from './monaco';
export { safe } from './safe';
export { sentry } from './sentry';
export { walletConnect } from './walletConnect';
export { vercel } from './vercel';
11 changes: 11 additions & 0 deletions nextjs/csp/policies/vercel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type CspDev from 'csp-dev';

export function vercel(): CspDev.DirectiveDescriptor {
return {
'script-src': [ 'https://vercel.live', 'https://vercel.com', 'https://va.vercel-scripts.com' ],
'font-src': [ 'https://assets.vercel.com' ],
'img-src': [ 'https://*.vercel.com', 'https://vercel.com' ],
'connect-src': [ 'https://vitals.vercel-insights.com', 'https://vercel.live' ],
'frame-src': [ 'https://vercel.live' ],
};
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": false,
"homepage": "https://github.com/blockscout/frontend#readme",
"engines": {
"node": "20.11.0",
"node": "20.x",
"npm": "10.2.4"
},
"scripts": {
"dev": "./tools/scripts/dev.sh",
"dev:preset": "./tools/scripts/dev.preset.sh",
"build": "next build",
"build": "./tools/scripts/build-fix.sh",
"build:docker": "docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t blockscout-frontend:local ./",
"start": "next start",
"start:docker:local": "docker run -p 3000:3000 --env-file .env.local blockscout-frontend:local",
Expand Down
24 changes: 24 additions & 0 deletions tools/scripts/build-fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# download assets for the running instance
dotenv \
-e .env.development.local \
-e .env.local \
-e .env.development \
-e .env \
-- bash -c './deploy/scripts/download_assets.sh ./public/assets'

yarn svg:build-sprite
echo ""

# generate envs.js file and run the app
dotenv \
-v NEXT_PUBLIC_GIT_COMMIT_SHA=1b10d15f \
-v NEXT_PUBLIC_GIT_TAG=v1.25.0-alpha.2 \
-e .env.secrets \
-e .env.development.local \
-e .env.local \
-e .env.development \
-e .env \
-- bash -c './deploy/scripts/make_envs_script.sh && next build' |
pino-pretty