Skip to content
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

Merged
merged 1 commit into from
Mar 19, 2025
Merged

Conversation

nighca
Copy link
Collaborator

@nighca nighca commented Mar 18, 2025

close #1466

Copy link

qiniu-prow bot commented Mar 18, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

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: '/(.*)',

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: '/(.*)',
@qiniu-ci
Copy link

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: '/(.*)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个规则要不要往后放?如果 vercel 规则按前面优先的顺序,可能大家都匹配到这个规则?

Copy link
Collaborator Author

@nighca nighca Mar 19, 2025

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

Copy link
Collaborator Author

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 部署后的效果,目前看行为是符合预期的

@nighca nighca merged commit db69ec9 into goplus:dev Mar 19, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update vercel config
3 participants