Skip to content

Commit f9c942c

Browse files
authored
Fix CORS error when loading icons in 2c (#3162)
1 parent eeb977f commit f9c942c

File tree

8 files changed

+165
-84
lines changed

8 files changed

+165
-84
lines changed

.github/composite/deploy-cloudflare/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ runs:
7070
apiToken: ${{ inputs.apiToken }}
7171
accountId: ${{ inputs.accountId }}
7272
workingDirectory: ./
73-
wranglerVersion: '3.112.0'
73+
wranglerVersion: '4.10.0'
7474
environment: ${{ inputs.environment }}
7575
command: ${{ inputs.deploy == 'true' && 'deploy' || format('versions upload --tag {0} --message "{1}"', inputs.commitTag, inputs.commitMessage) }} --config ./packages/gitbook-v2/wrangler.jsonc
7676
- name: Outputs

bun.lock

+139-57
Large diffs are not rendered by default.

packages/cache-do/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
},
2222
"devDependencies": {
2323
"typescript": "^5.5.3",
24-
"wrangler": "^3.112.0"
24+
"wrangler": "^4.10.0"
2525
},
2626
"scripts": {
27-
"generate": "wrangler types --experimental-include-runtime",
27+
"generate": "wrangler types",
2828
"build": "tsc",
2929
"typecheck": "tsc --noEmit",
3030
"dev": "tsc -w",

packages/cache-do/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"incremental": true,
17-
"types": ["./.wrangler/types/runtime.d.ts"]
17+
"types": ["./worker-configuration.d.ts"]
1818
},
1919
"include": ["src/**/*.ts"],
2020
"exclude": ["node_modules"]

packages/gitbook-v2/next.config.mjs

+18
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ const nextConfig = {
5353
},
5454
],
5555
},
56+
57+
async headers() {
58+
return [
59+
{
60+
source: '/~gitbook/static/:path*',
61+
headers: [
62+
{
63+
key: 'Cache-Control',
64+
value: 'public, max-age=31536000, immutable',
65+
},
66+
{
67+
key: 'Access-Control-Allow-Origin',
68+
value: '*',
69+
},
70+
],
71+
},
72+
];
73+
},
5674
};
5775

5876
export default nextConfig;

packages/gitbook-v2/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"devDependencies": {
1919
"gitbook": "*",
20-
"@opennextjs/cloudflare": "https://pkg.pr.new/opennextjs/opennextjs-cloudflare/@opennextjs/cloudflare@8f7ed38",
20+
"@opennextjs/cloudflare": "^1.0.0-beta.3",
2121
"@types/rison": "^0.0.9",
2222
"tailwindcss": "^3.4.0",
2323
"postcss": "^8"

packages/gitbook-v2/wrangler.jsonc

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"main": ".open-next/worker.js",
33
"name": "gitbook-open-v2",
4-
"compatibility_date": "2025-03-11",
4+
"compatibility_date": "2025-04-14",
55
"compatibility_flags": ["nodejs_compat", "allow_importable_env"],
66
"assets": {
77
"directory": ".open-next/assets",
@@ -12,13 +12,6 @@
1212
},
1313
"env": {
1414
"preview": {
15-
"d1_databases": [
16-
{
17-
"binding": "NEXT_CACHE_D1",
18-
"database_id": "f59ddb40-ad72-4312-9395-0ac6a129af8e",
19-
"database_name": "gitbook-open-v2-tags-preview"
20-
}
21-
],
2215
"r2_buckets": [
2316
{
2417
"binding": "NEXT_INC_CACHE_R2_BUCKET",
@@ -55,13 +48,6 @@
5548
"bucket_name": "gitbook-open-v2-cache-staging"
5649
}
5750
],
58-
"d1_databases": [
59-
{
60-
"binding": "NEXT_CACHE_D1",
61-
"database_id": "9df62e39-1f35-4066-83aa-e9b8ed3ac8d5",
62-
"database_name": "gitbook-open-v2-tags-staging"
63-
}
64-
],
6551
"services": [
6652
{
6753
"binding": "WORKER_SELF_REFERENCE",
@@ -113,13 +99,6 @@
11399
"bucket_name": "gitbook-open-v2-cache-production"
114100
}
115101
],
116-
"d1_databases": [
117-
{
118-
"binding": "NEXT_CACHE_D1",
119-
"database_id": "a6f16fce-5f45-43a9-89a4-7b83ddf25b77",
120-
"database_name": "gitbook-open-v2-tags-production"
121-
}
122-
],
123102
"services": [
124103
{
125104
"binding": "WORKER_SELF_REFERENCE",

packages/gitbook/public/_headers

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# GitBook immutable static assets
2+
# Duplicated from next.config.mjs until OpenNext supports generating static headers
23
/~gitbook/static/*
34
cache-control: public,max-age=31536000,immutable
5+
Access-Control-Allow-Origin: *

0 commit comments

Comments
 (0)