Skip to content

fix: front-end cannot load SERVER_BASE_URL #90

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

duhaode520
Copy link
Contributor

The front-end cannot load SERVER_BASE_URL, it can only load env variables with NEXT_PUBLIC_ prefix

Copy link

@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.

Hello @duhaode520, 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!

Summary of Changes

This pull request addresses an issue where the front-end was unable to load the SERVER_BASE_URL environment variable. The fix involves changing the environment variable name to NEXT_PUBLIC_SERVER_BASE_URL in several files, as Next.js only exposes environment variables with the NEXT_PUBLIC_ prefix to the client-side code. This change ensures that the front-end can correctly access the server's base URL.

Highlights

  • Environment Variable Update: The primary change is renaming SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL to make it accessible to the front-end.
  • Dockerfile Modification: The Dockerfile is updated to use the new environment variable name.
  • Documentation Update: The README.md and its translations (README.kr.md, README.vi.md) are updated to reflect the new environment variable name.
  • Configuration Update: The docker-compose.yml and next.config.ts files are updated to use the new environment variable name.
  • API Route Update: The src/app/api/chat/stream/route.ts file is updated to use the new environment variable name.

Changelog

Click here to see the changelog
  • Dockerfile
    • Changed environment variable SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 79.
  • README.kr.md
    • Updated documentation to reflect the change from SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 175.
  • README.md
    • Updated documentation to reflect the change from SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 177.
  • README.vi.md
    • Updated documentation to reflect the change from SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 175.
  • docker-compose.yml
    • Changed environment variable SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 14.
  • next.config.ts
    • Changed environment variable SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 3.
  • src/app/api/chat/stream/route.ts
    • Changed environment variable SERVER_BASE_URL to NEXT_PUBLIC_SERVER_BASE_URL on line 5.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


A variable's plight,
Not public, hid from sight,
NEXT_PUBLIC_,
Brings it to thee,
Front-end loads, shining bright.

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.

Copy link

@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

The pull request addresses the issue where the front-end could not load the SERVER_BASE_URL environment variable. The changes involve renaming the environment variable to NEXT_PUBLIC_SERVER_BASE_URL in the Dockerfile, docker-compose.yml, next.config.ts, and src/app/api/chat/stream/route.ts, and updating the README files accordingly. Overall, the changes seem correct and necessary to fix the issue.

Merge Readiness

The pull request appears to correctly address the reported issue. All changes seem logically sound and consistent across the relevant files. Given the nature of the fix, I recommend merging this pull request after another team member reviews and approves it. I am unable to directly approve the pull request, and users should have others review and approve this code before merging.

@sng-asyncfunc
Copy link
Contributor

@JNLei ^ will this affect you? Seems like you both have contradicting changes.

@JNLei
Copy link
Contributor

JNLei commented May 11, 2025

Hi @duhaode520 , we shouldn't need to use SERVER_BASE_URL in frontend anymore as there was a PR to add Next.js APIs, so the server base URL should only be used by API handlers, which is considered as "backend" in Next.js part.

@JNLei
Copy link
Contributor

JNLei commented May 11, 2025

@JNLei ^ will this affect you? Seems like you both have contradicting changes.

Yeah, thanks for checking. Let's better understand the usage case before merging. Thanks!

@sng-asyncfunc
Copy link
Contributor

@JNLei I merged your PR in, and @duhaode520 is raising an issue with it.

@JNLei
Copy link
Contributor

JNLei commented May 11, 2025

@JNLei I merged your PR in, and @duhaode520 is raising an issue with it.

Sorry to ping you again @duhaode520 . Could you please quickly describe the issue you had? I checked Discord but we have a long chat history so I did not find the issue you had. Thanks!

@duhaode520
Copy link
Contributor Author

@JNLei I merged your PR in, and @duhaode520 is raising an issue with it.

Sorry to ping you again @duhaode520 . Could you please quickly describe the issue you had? I checked Discord but we have a long chat history so I did not find the issue you had. Thanks!

While configuring SERVER_BASE_URL, I noticed it's not taking effect in app/page.tsx. When accessing config/generators, it can only reach localhost:8081.
https://github.com/AsyncFuncAI/deepwiki-open/blob/main/src/app/page.tsx#L102

There might also be an issue with the API request method in page.tsx. As I'm not a Next.js expert, I might need your assistance to troubleshoot this problem.

@JNLei
Copy link
Contributor

JNLei commented May 11, 2025

@JNLei I merged your PR in, and @duhaode520 is raising an issue with it.

Sorry to ping you again @duhaode520 . Could you please quickly describe the issue you had? I checked Discord but we have a long chat history so I did not find the issue you had. Thanks!

While configuring SERVER_BASE_URL, I noticed it's not taking effect in app/page.tsx. When accessing config/generators, it can only reach localhost:8081.

https://github.com/AsyncFuncAI/deepwiki-open/blob/main/src/app/page.tsx#L102

There might also be an issue with the API request method in page.tsx. As I'm not a Next.js expert, I might need your assistance to troubleshoot this problem.

Ah,I see. Since we have API route already, we can introduce a new API to fetch the available models. I'll have a PR tomorrow to address this. Thanks!

@duhaode520
Copy link
Contributor Author

ok then this could be close after your PR merged

@JNLei
Copy link
Contributor

JNLei commented May 11, 2025

Looks like this has been addressed by PR #74 @duhaode520 .
cc: @sng-asyncfunc

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.

3 participants