add cors middleware
This commit is contained in:
parent
ebea9faabf
commit
3e9f97e0e0
@ -1,4 +1,5 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
import models
|
import models
|
||||||
from database import engine
|
from database import engine
|
||||||
@ -6,6 +7,14 @@ from routers import auth, forum
|
|||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=['*'],
|
||||||
|
allow_credentials=False,
|
||||||
|
allow_methods=['GET', 'POST'],
|
||||||
|
allow_headers=['*']
|
||||||
|
)
|
||||||
|
|
||||||
models.Base.metadata.create_all(bind=engine)
|
models.Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
app.include_router(forum.router)
|
app.include_router(forum.router)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const apiUrl = 'http://localhost:8000/api';
|
const apiUrl = 'http://localhost:8001';
|
||||||
|
|
||||||
function getCatalog() {
|
function getCatalog() {
|
||||||
$.getJSON(apiUrl + "/catalog", function (resp) {
|
$.getJSON(apiUrl + "/catalog", function (resp) {
|
||||||
document.write(resp.text);
|
console.log(resp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user