-
Notifications
You must be signed in to change notification settings - Fork 33
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
Update vercel config for cache-control #1477
Conversation
Skipping CI for Draft Pull Request. |
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.
Pull Request Overview
This pull request updates the Vercel configuration in the Vite config file to adjust caching policies and routing behaviors.
- Updated caching headers for different resource groups.
- Reordered and revised route patterns for assets, widgets, and spx_* files to apply new cache durations and cross-origin policies.
Comments suppressed due to low confidence (1)
spx-gui/vite.config.ts:63
- The use of a catch-all pattern ('/(.*)') may unintentionally override more specific routes defined later. Consider narrowing the match or reordering the rules to ensure that specific paths receive the intended headers.
source: '/(.*)',
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.
Pull Request Overview
This pull request updates the Vercel configuration to adjust cache-control and redirection behavior, while also updating asset URLs and environment variable usage.
- Updated header rewrites and caching configuration in vite.config.ts
- Added environment variables and logging in cloud.ts to warn on misconfiguration
- Updated Monaco Editor asset paths in code-editor configuration
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
File | Description |
---|---|
spx-gui/vite.config.ts | Revised header rewrite rules and comments for cache-control |
spx-gui/src/models/common/cloud.ts | Added logging to warn about mismatched usercontentBaseUrl |
spx-gui/src/components/editor/code-editor/monaco.ts | Updated asset URL construction using an env variable |
spx-gui/src/utils/env.ts | Added new environment variables for static and usercontent URLs |
Comments suppressed due to low confidence (1)
spx-gui/vite.config.ts:63
- Ensure that applying Cache-Control headers to all paths (using the '/(.*)' pattern) is intended, as it might inadvertently affect non-asset routes.
source: '/(.*)',
This PR has been deployed to the preview environment. You can explore it using the preview URL. Warning Please note that deployments in the preview environment are temporary and will be automatically cleaned up after a certain period. Make sure to explore it before it is removed. For any questions, contact the Go+ Builder team. |
@@ -59,11 +60,19 @@ export default defineConfig(({ mode }) => { | |||
], | |||
headers: [ | |||
{ | |||
source: '/assets/(.*)', | |||
source: '/(.*)', |
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.
这个规则要不要往后放?如果 vercel 规则按前面优先的顺序,可能大家都匹配到这个规则?
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.
这里 headers 会被 vite-plugin-vercel
处理,最后转成 Vercel Output API (v3) 的 routes
配置,且带上 "continue": true
所以整体上是从前往后依次匹配,不过后边匹配上的项会覆盖前面的匹配项指定的同名 header;/(.*)
往后放的话会覆盖前面的 cache-control 配置,导致所有内容都 max-age=300
了
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.
在 https://builder-cnoy0jtk5-goplus.vercel.app/ 这里可以看到这个 PR 部署后的效果,目前看行为是符合预期的
close #1466