[GH-ISSUE #4264] [BUG]: Fly.io Deployment: POST requests to /api/* are served index.html #2715

Closed
opened 2026-02-22 18:30:55 -05:00 by yindo · 1 comment
Owner

Originally created by @aliyousaff on GitHub (Aug 8, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4264

How are you running AnythingLLM?

Docker (remote machine)

What happened?

After a successful deployment to Fly.io using the official Dockerfile, the application runs but is not functional. All POST requests to the API (e.g., /api/v1/chat) are not handled by the backend router. Instead, the server responds with the content of the frontend's index.html file.

This causes the frontend to fail with a SyntaxError: Unexpected token '<', ... is not valid JSON because it receives an HTML document instead of the expected JSON response.

Interestingly, GET requests to the API seem to work correctly. For example, navigating to /api/docs successfully displays the Swagger UI page. The issue appears to be specific to how POST requests are routed in the production Docker environment.

I expected a POST request to /api/v1/chat to be handled by the backend API and to receive a JSON response.

Are there known steps to reproduce?

Yes, the issue can be reproduced with the following steps:

Deploy to Fly.io:

Deploy the application to a new Fly.io instance using the official docker/Dockerfile.

Configure the fly.toml file to run one machine continuously (min_machines_running = 1) and add a grace_period (e.g., "30s") to ensure the server has time to boot.

Set all required secrets using fly secrets set: OPENAI_API_KEY, JWT_SECRET, SIG_KEY, SIG_SALT, PORT, and CORS_ORIGIN_WHITELIST.

Ensure the frontend/.env.production file exists in the repository with the content VITE_API_BASE='/api'.

Test the GET Endpoint (This works):

Once deployed, navigate to https:///api/docs.

Observe: The Swagger API documentation page loads correctly.

Test the POST Endpoint (This fails):

Use a command-line tool like curl or PowerShell's Invoke-WebRequest to send a POST request to the chat endpoint.

Command Example (PowerShell):

PowerShell

Invoke-WebRequest -Uri "https:///api/v1/chat" -Method POST -Headers @{"Authorization"="Bearer "} -Body '{"message":"hello"}'
Observe: The command completes with a 200 OK status, but the content of the response is the full HTML of the index.html page, not a JSON object.

Originally created by @aliyousaff on GitHub (Aug 8, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4264 ### How are you running AnythingLLM? Docker (remote machine) ### What happened? After a successful deployment to Fly.io using the official Dockerfile, the application runs but is not functional. All POST requests to the API (e.g., /api/v1/chat) are not handled by the backend router. Instead, the server responds with the content of the frontend's index.html file. This causes the frontend to fail with a SyntaxError: Unexpected token '<', ... is not valid JSON because it receives an HTML document instead of the expected JSON response. Interestingly, GET requests to the API seem to work correctly. For example, navigating to /api/docs successfully displays the Swagger UI page. The issue appears to be specific to how POST requests are routed in the production Docker environment. I expected a POST request to /api/v1/chat to be handled by the backend API and to receive a JSON response. ### Are there known steps to reproduce? Yes, the issue can be reproduced with the following steps: Deploy to Fly.io: Deploy the application to a new Fly.io instance using the official docker/Dockerfile. Configure the fly.toml file to run one machine continuously (min_machines_running = 1) and add a grace_period (e.g., "30s") to ensure the server has time to boot. Set all required secrets using fly secrets set: OPENAI_API_KEY, JWT_SECRET, SIG_KEY, SIG_SALT, PORT, and CORS_ORIGIN_WHITELIST. Ensure the frontend/.env.production file exists in the repository with the content VITE_API_BASE='/api'. Test the GET Endpoint (This works): Once deployed, navigate to https://<your-app-hostname>/api/docs. Observe: The Swagger API documentation page loads correctly. Test the POST Endpoint (This fails): Use a command-line tool like curl or PowerShell's Invoke-WebRequest to send a POST request to the chat endpoint. Command Example (PowerShell): PowerShell Invoke-WebRequest -Uri "https://<your-app-hostname>/api/v1/chat" -Method POST -Headers @{"Authorization"="Bearer <anythingllm-api-key>"} -Body '{"message":"hello"}' Observe: The command completes with a 200 OK status, but the content of the response is the full HTML of the index.html page, not a JSON object.
yindo added the possible bug label 2026-02-22 18:30:55 -05:00
yindo closed this issue 2026-02-22 18:30:55 -05:00
Author
Owner

@timothycarambat commented on GitHub (Aug 11, 2025):

Was this a config issue? If so please share just for others in the future that may find this issue - if you would like to share, of course

@timothycarambat commented on GitHub (Aug 11, 2025): Was this a config issue? If so please share just for others in the future that may find this issue - if you would like to share, of course
yindo changed title from [BUG]: Fly.io Deployment: POST requests to /api/* are served index.html to [GH-ISSUE #4264] [BUG]: Fly.io Deployment: POST requests to /api/* are served index.html 2026-06-05 14:48:07 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2715