Suha Karkhy
Suha Karkhy

Reputation: 71

flask and nextJS app deployment - POST route 404 Not Found

I am using a flask and NextJS to build a paraphrasing tool. I used Netlify to deploy my app because in vercel the build fails with Command "vercel build" exited with SIGKILL. I used this repo as an example to create my paraphrasing tool https://vercel.com/templates/next.js/nextjs-flask-starter

when in development, the route I use is http://127.0.0.1:3000/api/paraphrase and it works fine. but, when it is deployed it gives me 404 Not Found.

here is my index.py inside my api folder in my nextJS project:

from flask import Flask, request, jsonify
from paraphraser import paraphrase
from flask_cors import CORS

app = Flask(__name__)
CORS(app)

@app.route('/api/paraphrase', methods=['POST'])
def paraphrase_tool():
    data = request.get_json()
    question = data['question']

    # Invoke the paraphrase function from paraphraser.py
    paraphrased_result = paraphrase(question)

    return jsonify(result=paraphrased_result)

please help me solve this issue.

Upvotes: 0

Views: 149

Answers (1)

MoLeo
MoLeo

Reputation: 21

If you're using Netfily, There is no need to have this in your python file CORS(app) Try removing it to see if it works

Upvotes: 0

Related Questions