Skip to content

[Due for payment 2025-10-21] Fix the web production build locally not working #69854

Closed

Description

@mountiny

Coming from https://expensify.slack.com/archives/C08CZDJFJ77/p1749629334304079

Using the npm run web:prod seems to not work reliably and the app runs into the 404 issues. Let's make sure this flow works and developers can run and test the production web build

Issue OwnerCurrent Issue Owner: @abekkala

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 4, 2025
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 4, 2025
  3. melvin-bot commented on Sep 4, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @Pujan92 (External)

  4. melvin-bot commented on Sep 4, 2025

    @melvin-bot

    Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. PiyushChandra17 commented on Sep 4, 2025

    @PiyushChandra17
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Fix the web production build locally not working

    What is the root cause of that problem?

    Improvement

    What changes do you think we should make in order to solve the problem?

    We need replace http-server with serve here in order to avoid 404 issues

    "web:prod": "http-server ./dist --cors",

     "web:prod": "npx serve ./dist --cors",

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    n/A

    What alternative solutions did you explore? (Optional)

    n/A

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  6. LukasMod commented on Sep 4, 2025

    @LukasMod
    Contributor

    Currently, the README instructions for production build is:

    #### Local production build of the web app
    In order to generate a production web build, run `npm run build`, this will generate a production javascript build in the `dist/` folder.
    

    Standard development builds are run with npm run web. For production builds, there is an additional script: npm run web:prod. We can assume that this is proper way to build and run locally production web:

    npm run build
    npm run web:prod
    

    This successfully starts the local production website, but API requests return a CORS errors or 404 errors (depends on USE_WEB_PROXY env flag). There are likely additional steps required to make it work, possibly including changes to environment files that should be documented in the README or additional proxy commend.

    @PiyushChandra17 I tried your solution but it didn’t work. Could you check if there are any additional settings in the environment files? Is there any command that should be run besides these two?

    with USE_WEB_PROXY true:

    Image
  7. PiyushChandra17 commented on Sep 4, 2025

    @PiyushChandra17
    Contributor

    @LukasMod In the env prod, we can set USE_WEB_PROXY ENV flag to true here

    USE_WEB_PROXY=false

    And -P additional proxy flag

    "web:prod": "http-server ./dist --cors -P http://localhost:8080?"

  8. LukasMod commented on Sep 4, 2025

    @LukasMod
    Contributor

    @PiyushChandra17 I did try with that proposition "web:prod": "http-server ./dist --cors -P http://localhost:8080?" and USE_WEB_PROXY set to true in env.production, but got loop with wrong requests in terminal and still offline indicator in web (there is no 404 requests, but it seems not right in terminal for sure).

    Image
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
    [2025-09-04T12:49:49.048Z]  "POST ?/(..)/?/?/?/?/?/?/?/?/?/?/?/?/?/api/SendPerformanceTiming?"
    

    On your side, are you able to interact or log in normally after running that command? I wonder if there’s something else that needs to be configured to make this work.

  9. PiyushChandra17 commented on Sep 4, 2025

    @PiyushChandra17
    Contributor

    @LukasMod This is exactly what's happening

    • USE_WEB_PROXY=true - > the app expects the local dev proxy to forward API calls, this kinda works with npm run web but not with npm run web:prod

    • USE_WEB_PROXY=false - > the app calls the prod API directly - > which leads to CORS/404 restrictions

    So just running

    1. npm run build
    2. npm run web:prod
      this isn't enough

    We need:

    1. Proper proxy set up for prod builds so the local server rewrites API BE
    2. Or correct .env overrides so the app points to the correct working production level BE without trigerring CORS issues

    We need to start the proxy server too along with those two commands

    "web-proxy": "ts-node web/proxy.ts",

  10. PiyushChandra17 commented on Sep 4, 2025

    @PiyushChandra17
    Contributor
    1. Set the USE_WEB_PROXY=true in .env prod
    2. Update the web:prod npm script if needed (just working on this and let's see what resolves the issue)
    3. Run web-proxy
    npm run build
    npm run web:prod
    npm run web-proxy
  11. 56 remaining items

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Oct 14, 2025
  13. changed the title [-]Fix the web production build locally not working[/-] [+][Due for payment 2025-10-21] Fix the web production build locally not working[/+] on Oct 14, 2025
  14. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  15. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.30-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-10-21. 🎊

    For reference, here are some details about the assignees on this issue:

    • @Pujan92 requires payment through NewDot Manual Requests
    • @TaduJR requires payment (Needs manual offer from BZ)
  16. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    @Pujan92 @abekkala The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  17. abekkala commented on Oct 16, 2025

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR OCT 21

    • Fix: @TaduJR [$250, if no regressions] payment via Upwork OFFER
    • PR Review: @Pujan92 [$250, if no regressions] payment via NewDot
      please complete checklist above - thanks!
  18. Pujan92 commented on Oct 16, 2025

    @Pujan92
    Contributor

    @abekkala no need for the checklist here.

  19. abekkala commented on Oct 17, 2025

    @abekkala
    Contributor

    Thank you @Pujan92

  20. abekkala commented on Oct 21, 2025

    @abekkala
    Contributor
    • Fix: @TaduJR payment sent via Upwork and contract ended!

    • PR Review: @Pujan92 [$250] payment via NewDot

    THANKS! 🎉

  21. JmillsExpensify commented on Oct 22, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @Pujan92

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions