Skip to content

chore: add dev proxy server, update deps#33371

Merged
hyoban merged 14 commits intomainfrom
3-12-vite-proxy
Mar 13, 2026
Merged

chore: add dev proxy server, update deps#33371
hyoban merged 14 commits intomainfrom
3-12-vite-proxy

Conversation

@hyoban
Copy link
Copy Markdown
Member

@hyoban hyoban commented Mar 12, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

fixes #33181

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Copilot AI review requested due to automatic review settings March 12, 2026 14:20
@github-actions github-actions bot added the web This relates to changes on the web. label Mar 12, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the local development experience by integrating a robust Vite proxy setup. It allows developers to seamlessly proxy API requests from their local frontend to a remote backend, which is particularly useful for environments where the frontend and backend are hosted separately. The core of this change lies in its intelligent handling of cookies, ensuring that authentication and session management work correctly across different domains during development, thereby streamlining the testing and debugging process.

Highlights

  • Vite Proxy Configuration: Introduced a new Vite proxy configuration to facilitate local development by routing API requests through the local dev server to a remote target.
  • Cookie Rewriting Logic: Implemented sophisticated cookie rewriting mechanisms to correctly handle __Host- and __Secure- prefixed cookies, as well as SameSite, Path, Domain, Secure, and Partitioned attributes when proxying requests.
  • Environment Variable Integration: Added new environment variables (VITE_CONSOLE_API_PROXY_TARGET, VITE_PUBLIC_API_PROXY_TARGET) to allow flexible configuration of the proxy targets for console and public APIs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • web/.env.example
    • Introduced VITE_CONSOLE_API_PROXY_TARGET and VITE_PUBLIC_API_PROXY_TARGET for configuring development proxy targets.
  • web/plugins/vite/proxy.ts
    • Created a new module proxy.ts to encapsulate Vite proxy configuration logic, specifically handling cookie rewriting for __Host- and __Secure- prefixes, SameSite, Path, Domain, Secure, and Partitioned attributes.
  • web/vite.config.ts
    • Imported loadEnv and createDevProxyConfig to enable dynamic proxy configuration.
    • Configured the Vite development server to use the new cookie-aware proxy, leveraging VITE_CONSOLE_API_PROXY_TARGET and VITE_PUBLIC_API_PROXY_TARGET environment variables.
Activity
  • No specific review comments or discussions have been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

lyzno1
lyzno1 previously approved these changes Mar 12, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Vite dev-server proxy to route /console/api and /api requests through the local dev server (including cookie rewriting) so developers can work against remote targets without CORS/cookie issues.

Changes:

  • Load Vite env vars in vite.config.ts and wire server.proxy to a new proxy factory.
  • Add web/plugins/vite/proxy.ts implementing a cookie-aware proxy (Cookie + Set-Cookie rewriting).
  • Document new dev-only proxy target env vars in web/.env.example.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
web/vite.config.ts Loads env via loadEnv and configures Vite server.proxy using createDevProxyConfig.
web/plugins/vite/proxy.ts New proxy helper that rewrites cookie names/attributes when proxying /console/api and /api.
web/.env.example Adds VITE_CONSOLE_API_PROXY_TARGET / VITE_PUBLIC_API_PROXY_TARGET example values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a robust Vite proxy configuration designed to streamline local development by correctly handling API requests and complex cookie management. The new proxy.ts file provides a well-thought-out solution for rewriting __Host- and __Secure- prefixed cookies, as well as adjusting SameSite, Domain, and Secure attributes, which are crucial for successful proxying to a secure backend. The integration into vite.config.ts and the addition of corresponding environment variables in .env.example are correctly implemented. Overall, the changes are logical, well-structured, and effectively address the technical challenges of proxying in a development environment.

Copilot AI review requested due to automatic review settings March 12, 2026 14:55
@hyoban hyoban review requested due to automatic review settings March 12, 2026 14:55
Copilot AI review requested due to automatic review settings March 12, 2026 15:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 13, 2026 00:55
@hyoban hyoban changed the title chore: add vite proxy config chore: add vite proxy config, update deps Mar 13, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 13, 2026 01:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 13, 2026 01:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 13, 2026 02:52
@hyoban hyoban changed the title chore: add vite proxy config, update deps chore: add vite proxy server, update deps Mar 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hyoban hyoban marked this pull request as ready for review March 13, 2026 04:50
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 13, 2026
@hyoban hyoban changed the title chore: add vite proxy server, update deps chore: add dev proxy server, update deps Mar 13, 2026
@hyoban hyoban merged commit 724eaee into main Mar 13, 2026
30 checks passed
@hyoban hyoban deleted the 3-12-vite-proxy branch March 13, 2026 04:52
@bowenliang123
Copy link
Copy Markdown
Contributor

Hi @hyoban , are the "hono" and "@hono/node-server" used only in development? Shall we move them from "dependencies" to "devDependencies" instead ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] use agent reporter for vitest

4 participants