English 中文(简体)
FLASK + VUE: Blocked by CORS policy: Response to prelew request don t Pass controleck: 它没有吉大港定居地。
原标题:FLASK + VUE: Blocked by CORS policy: Response to preflight request doesn t pass access control check: It does not have HTTP ok status

这是我的表象:

const API_ROOT = import.meta.env.VITE_API_ROOT as string;

export function rest(url: string, body?: unknown, method?: string, headers?: HeadersInit){

    return fetch(url, {
        method: method ?? (body ? "POST" : "GET"),
        headers: {
             Content-Type :  application/json ,
            ...headers
        },
        body: body ? JSON.stringify(body) : undefined
    })
        .then(response => response.ok 
            ? response.json()
            : response.json().then(err => Promise.reject(err))    )
}

export function api(action: string, body?: unknown, method?: string, headers?: HeadersInit){
    return rest(`${API_ROOT}/${action}`, body, method, headers);
}

我的评价职能包括:

CORS(app)

并适当列入我试图进入的路线蓝图。 当我使用邮政员时,该路线就行驶。

我试图通过人工方式确定索再解放联盟的负责人。

@app.after_request
def after_request(response):
    response.headers.add( Access-Control-Allow-Origin ,  http://localhost:5173 )
    response.headers.add( Access-Control-Allow-Headers ,  Content-Type )
    response.headers.add( Access-Control-Allow-Methods ,  OPTIONS, GET )
    response.headers.add( Access-Control-Allow-Credentials ,  true )
    return response

我也试图在我的道路上增加一个勋章:

@cross_origin(origin="http://localhost:5173", supports_credentials=True)

我试图在方法上将《任择议定书》方法人工添加到我的其余部分:

    const actualMethod = method === "OPTIONS" ? "OPTIONS" : method ?? (body ? "POST" : "GET");

But nothing is working! I still get the error: Access to fetch at http://localhost:8000/api/v1/ports/getports from origin http://localhost:5173 has been blocked by CORS policy: Response to preflight request doesn t pass access control check: It does not have HTTP ok status.

And this one: GET http://localhost:8000/api/v1/ports/getports net::ERR_FAILED

而后又发生了Fetch错误。

如果人人都能有热情的见解,就会感谢你!

问题回答

www.un.org/Depts/DGACM/index_spanish.htm 您在哪一个服务器上托管服务? 我与阿帕奇和购买力平价有着类似的问题,问题在于亚普森,而服务器则要求残疾。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签