Question 26
Given the Flask app:
from flask import Flaskfrom flask_cors import CORS
app = Flask(__name__)CORS(app, resources={r"/api/*": {"origins": "http://localhost:3000"}})
@app.route('/api/data')def data(): return {"msg": "Success"}frontend code:
fetch("http://localhost:5000/api/data") .then(res => res.json()) .then(data => console.log(data));What will happen when run from a Vue app hosted at http://localhost:5173?
Request succeeds
CORS error occurs
404 error
The server crashes