Почему запросы к flask backend на localhost возвращют правильные данные, а на сервере - Стандартную React страницу?

Есть такой код функцианального компонента:

import React from 'react'
import ProductCard from '../../Components/ProductCard/ProductCard'
import { Helmet } from 'react-helmet'
import { useState } from 'react'
import './buy.scss'

import { useEffect } from 'react'
import axios, { AxiosHeaders } from 'axios'
import {PayPalScriptProvider} from "@paypal/react-paypal-js"

let month_and_prices = []

async function getprices_from_server  (prices) {
    if (!localStorage.getItem('prices')){
    let data = JSON.stringify(prices)
    const json_data = {"year_prices": data}
    
    month_and_prices = await axios.post(`http://localhost:5000/prices/`, json_data, new AxiosHeaders("Access-Control-Allow-Origin: *")).then(async (response) => { return await response.data})
    //month_and_prices = await axios.post('http://www.<domain>.com/prices/', json_data, new AxiosHeaders("Access-Control-Allow-Origin: *")).then(async (response) => { return await response.data})
    
    return month_and_prices
}
}

export default function Buy() {

    const initialOptions = {
          clientId: "client-id",
          currency: "USD",
          intent: "capture",
        }
    useEffect(() => {
        window.addEventListener("load", handleLoad);
        return () => {
            window.removeEventListener("load", handleLoad);
        };
    });


    const [prices, setPrices] = useState([])
    const [monthLeft, setMonthLeft] = useState(12)
    const [monthNames, setMonthNames] = useState([])
    const handleLoad = async () => {

        let month_and_prices = await getprices_from_server([10, 20, 10, 20, 10, 20])
        if (month_and_prices['month_left'] !== undefined){
        setMonthLeft(month_and_prices['month_left'])
        setPrices(month_and_prices['prices'])
        setMonthNames(month_and_prices['month_names'])
        }
        console.log(month_and_prices)
    }
    

    return (
    <PayPalScriptProvider options={initialOptions}>
    <div className='buy__page page'>
    <Helmet><title>123Cluster Products</title></Helmet>
    <h1 className='buy__title'>Oracle & SQLServer</h1>
    
     <div className='product__container'>
        <ProductCard text_id = "FreeOracleCard" title = "Free" buttonLabel = "Sign in" description__items = {["Free monitoring module", "Unlimited nodes", "Node Dashboard", "Up to 10 daily notifications"]} span__items = {["No online support"]} moduleName="Oracle & SQLServer" monthNames = {monthNames}   ></ProductCard>
        <ProductCard text_id = "StandardOracleCard" title = "Standard" buttonLabel = "Buy" description__items = {["Full monitoring module", "Clustering", "Backup and restore", "Unlimited notifications"]} span__items = {["Mail support during work hours", "First month is free", "Full year subscription : 10$"]} price={prices[0] + "$"} month_left= {monthLeft} monthNames = {monthNames} moduleName="Oracle & SQLServer"   ></ProductCard>
        <ProductCard text_id = "AdvansedOracleCard" title = "Advanced" buttonLabel = "Buy" description__items = {["All modules", "Unlimited notifications", "Mail support 24X7", "First month is free"]} span__items = {["Full year subscription : 20$"]} price={prices[1] + "$"} month_left= {monthLeft} monthNames = {monthNames} moduleName="Oracle & SQLServer"  ></ProductCard>
     </div>
     
     <h1 className='buy__title'>PostgreSQL, MySQL, MariaDB & MongoDB</h1>
     <div className='product__container'>
        <ProductCard text_id = "FreeOracleCard" title = "Free" buttonLabel = "Sign in" description__items = {["Free monitoring module", "Unlimited nodes", "Node Dashboard", "Up to 10 daily notifications"]} span__items = {["No online support"]} moduleName="PostgreSQL, MySQL, MariaDB & MongoDB"  monthNames={monthNames}></ProductCard>
        <ProductCard text_id = "StandardOracleCard" title = "Standard" buttonLabel = "Buy" description__items = {["Full monitoring module", "Clustering", "Backup and restore", "Unlimited notifications"]} span__items = {["Mail support during work hours", "First month is free", "Full year subscription : 10$"]} price={prices[2]+"$"} month_left= {monthLeft} moduleName='PostgreSQL, MySQL, MariaDB & MongoDB'  monthNames={monthNames}></ProductCard>
        <ProductCard text_id = "AdvansedOracleCard" title = "Advanced" buttonLabel = "Buy" description__items = {["All modules", "Unlimited notifications", "Mail support 24X7", "First month is free"]} span__items = {["Full year subscription : 20$"]} price = {prices[3]+"$"} month_left= {monthLeft} moduleName='PostgreSQL, MySQL, MariaDB & MongoDB' monthNames={monthNames}  ></ProductCard>
     </div>

     <h1 className='buy__title'>Redis & ElasticSearch</h1>
     <div className='product__container'>
        <ProductCard text_id = "FreeOracleCard" title = "Free" buttonLabel = "Sign in" description__items = {["Free monitoring module", "Unlimited nodes", "Node Dashboard", "Up to 10 daily notifications"]} span__items = {["No online support"]} moduleName="Redis & Elasticsearch"  ></ProductCard>
        <ProductCard text_id = "StandardOracleCard" title = "Standard" buttonLabel = "Buy" description__items = {["Full monitoring module", "Clustering", "Backup and restore", "Unlimited notifications"]} span__items = {["Mail support during work hours", "First month is free", "Full year subscription : 10$"]} month_left= {monthLeft} price={prices[4]+"$"} moduleName="Redis & Elasticsearch" monthNames = {monthNames}  ></ProductCard>
        <ProductCard text_id = "AdvansedOracleCard" title = "Advanced" buttonLabel = "Buy" description__items = {["All modules", "Unlimited notifications", "Mail support 24X7", "First month is free"]} span__items = {["Full year subscription : 20$"]} price = {prices[5]+"$"} month_left= {monthLeft} moduleName="Redis & Elasticsearch" monthNames = {monthNames}  > </ProductCard>
     </div>

    </div>
    </PayPalScriptProvider>
    
  )
}

И flask route:

from flask import Flask, redirect, Response, request, url_for, current_app
from flask_cors import CORS, cross_origin

def get_prices():
 if request.method == "POST":
    try:
        current_month = datetime.now().month
        # current_month = 11
        
        month_left = 12 - current_month
        month_names =[]

        i = 0
        while i < month_left + 1:
            month_names.append(calendar.month_name[i+current_month])
            i+=1


        data = request.json
        year_prices = data["year_prices"].strip("[]").split(",")
        prices = []
        for year_price in year_prices:
            year_price = int(year_price)
            month_price = year_price / 12
            if current_month == 11:
                price = round((month_price * 12), 2)
            if current_month == 12:
                price = round((month_price * 11), 2)
            else:
                price = round(( (month_left-1) * month_price), 2)
            
            prices.append(price)
       
 
        return {"month_names":month_names, "month_left": month_left-1, "prices": prices}
    except Exception as e:
        
        return f"An error occurred while calculate prices: {e}"
 else: return "returnin index.html instead of prices"

app = Flask(__name__)
cors = CORS(app)

@app.route('/prices/', methods=["POST"])
@cross_origin()
def prices():
    return get_prices()

Когда я запускаю приложения на localhost и шлю запрос к нему - из бекенда возвращаются правильные данные, а именно объект с ценами:

введите сюда описание изображения

Но когда делаю тот же запрос на сервер - flask возвращает стандартную react разметку. Почему? Как поправить? Вот, что приходит, когда запрашиваю данные с сервера:

введите сюда описание изображения

Frontent build запущен через httpd (apache), backend - через gunicorn.


Ответы (0 шт):