@@ -207,64 +207,68 @@ const nextConfig = {
207207 {
208208 source : '/:path*{/}?' ,
209209 headers : [
210- // 安全头部
211- { key : 'X-Frame-Options' , value : 'DENY' } ,
212- { key : 'X-Content-Type-Options' , value : 'nosniff' } ,
213- { key : 'X-XSS-Protection' , value : '1; mode=block' } ,
214- { key : 'Referrer-Policy' , value : 'strict-origin-when-cross-origin' } ,
215- { key : 'Permissions-Policy' , value : 'camera=(), microphone=(), geolocation=()' } ,
216- {
217- key : 'Strict-Transport-Security' ,
218- value : 'max-age=31536000; includeSubDomains; preload'
219- } ,
220- {
221- key : 'Content-Security-Policy' ,
222- value : [
223- "default-src 'self'" ,
224- "script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googleapis.com *.gstatic.com *.google-analytics.com *.googletagmanager.com" ,
225- "style-src 'self' 'unsafe-inline' *.googleapis.com *.gstatic.com" ,
226- "img-src 'self' data: blob: *.notion.so *.unsplash.com *.githubusercontent.com *.gravatar.com" ,
227- "font-src 'self' *.googleapis.com *.gstatic.com" ,
228- "connect-src 'self' *.google-analytics.com *.googletagmanager.com" ,
229- "frame-src 'self' *.youtube.com *.vimeo.com" ,
230- "object-src 'none'" ,
231- "base-uri 'self'" ,
232- "form-action 'self'"
233- ] . join ( '; ' )
234- } ,
235-
236- // CORS 配置(更严格)
237- { key : 'Access-Control-Allow-Credentials' , value : 'false' } ,
238- {
239- key : 'Access-Control-Allow-Origin' ,
240- value : process . env . NODE_ENV === 'production'
241- ? siteConfig ( 'LINK' ) || 'https://yourdomain.com'
242- : '*'
243- } ,
210+ // 为了博客兼容性,不做过多安全限制
211+ { key : 'Access-Control-Allow-Credentials' , value : 'true' } ,
212+ { key : 'Access-Control-Allow-Origin' , value : '*' } ,
244213 {
245214 key : 'Access-Control-Allow-Methods' ,
246- value : 'GET,OPTIONS,HEAD '
215+ value : 'GET,OPTIONS,PATCH,DELETE,POST,PUT '
247216 } ,
248217 {
249218 key : 'Access-Control-Allow-Headers' ,
250- value : 'Accept, Accept-Version, Content-Length, Content-Type, Date'
251- } ,
252- { key : 'Access-Control-Max-Age' , value : '86400' }
253- ]
254- } ,
255- {
256- source : '/api/:path*' ,
257- headers : [
258- // API 特定的安全头部
259- { key : 'X-Frame-Options' , value : 'DENY' } ,
260- { key : 'X-Content-Type-Options' , value : 'nosniff' } ,
261- { key : 'Cache-Control' , value : 'no-store, max-age=0' } ,
262- {
263- key : 'Access-Control-Allow-Methods' ,
264- value : 'GET,POST,PUT,DELETE,OPTIONS'
219+ value :
220+ 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version'
265221 }
222+ // 安全头部 相关配置,谨慎开启
223+ // { key: 'X-Frame-Options', value: 'DENY' },
224+ // { key: 'X-Content-Type-Options', value: 'nosniff' },
225+ // { key: 'X-XSS-Protection', value: '1; mode=block' },
226+ // { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
227+ // { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
228+ // {
229+ // key: 'Strict-Transport-Security',
230+ // value: 'max-age=31536000; includeSubDomains; preload'
231+ // },
232+ // {
233+ // key: 'Content-Security-Policy',
234+ // value: [
235+ // "default-src 'self'",
236+ // "script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googleapis.com *.gstatic.com *.google-analytics.com *.googletagmanager.com",
237+ // "style-src 'self' 'unsafe-inline' *.googleapis.com *.gstatic.com",
238+ // "img-src 'self' data: blob: *.notion.so *.unsplash.com *.githubusercontent.com *.gravatar.com",
239+ // "font-src 'self' *.googleapis.com *.gstatic.com",
240+ // "connect-src 'self' *.google-analytics.com *.googletagmanager.com",
241+ // "frame-src 'self' *.youtube.com *.vimeo.com",
242+ // "object-src 'none'",
243+ // "base-uri 'self'",
244+ // "form-action 'self'"
245+ // ].join('; ')
246+ // },
247+
248+ // // CORS 配置(更严格)
249+ // { key: 'Access-Control-Allow-Credentials', value: 'false' },
250+ // {
251+ // key: 'Access-Control-Allow-Origin',
252+ // value: process.env.NODE_ENV === 'production'
253+ // ? siteConfig('LINK') || 'https://yourdomain.com'
254+ // : '*'
255+ // },
256+ // { key: 'Access-Control-Max-Age', value: '86400' }
266257 ]
267- }
258+ } ,
259+ // {
260+ // source: '/api/:path*',
261+ // headers: [
262+ // // API 特定的安全头部
263+ // { key: 'X-Frame-Options', value: 'DENY' },
264+ // { key: 'X-Content-Type-Options', value: 'nosniff' },
265+ // { key: 'Cache-Control', value: 'no-store, max-age=0' },
266+ // {
267+ // key: 'Access-Control-Allow-Methods',
268+ // value: 'GET,POST,PUT,DELETE,OPTIONS'
269+ // }
270+ // ]
271+ // }
268272 ]
269273 } ,
270274 webpack : ( config , { dev, isServer } ) => {
0 commit comments