设置标头后,为什么我仍然会在Apollo Studio中遇到CORS问题?
我正在从事使用OIDC的服务。会话ID存储在一个名为Pat的曲奇中。我可以使用Postman与GraphQL服务进行交互,因此我知道服务本身正在工作。但是,当我尝试与工作室访问时,它会失败。这是服务器...
import {ApolloServer} from "apollo-server";
import config from "./graphql/index.mjs"
class EddieBrockApp {
constructor(schema, plugin){
this.server = new ApolloServer({
config,
schema,
plugins: [plugin],
cors: {
origin: ["https://mysite.co", "https://studio.apollographql.com"],
credentials: true,
},
});
}
start(){
this.server.listen({port: 4200})
.then(this.onStart)
}
onStart({url}){
console.log("Started at ", url);
}
}
export default EddieBrockApp
Studio显示2个调用一个呼叫cors失败
消息的选项,一个发表ns_error_dom_bad_uri
我尝试添加一个函数以显式设置标题...
context: ({res}) => {
res.header('test-header', 'my-header');
res.header('Vary', 'Origin');
res.header('Access-Control-Allow-Origin', 'https://studio.apollographql.com');
}
我看到了标题...
我尝试他们的调试,然后得到...
npx [email protected] --endpoint=https://mysite.co
但是我得到了...
⚠️ OPTIONS response returned 404. Is the url correct? Are authorization headers or cookies required?
⚠️ OPTIONS response is missing header 'access-control-allow-methods: POST'
⚠️ POST response returned 404. Is the url correct? Are authorization headers or cookies required?
⚠️ POST response missing 'access-control-allow-origin' header.
我在做什么错,我如何避免这些CORS问题?
I am working on a service that uses OIDC. The session ID is stored in a cookie called PAT. I can interact with the graphql service using Postman so I know the service itself is working. However, when I try to access with the studio it fails. Here is the server...
import {ApolloServer} from "apollo-server";
import config from "./graphql/index.mjs"
class EddieBrockApp {
constructor(schema, plugin){
this.server = new ApolloServer({
config,
schema,
plugins: [plugin],
cors: {
origin: ["https://mysite.co", "https://studio.apollographql.com"],
credentials: true,
},
});
}
start(){
this.server.listen({port: 4200})
.then(this.onStart)
}
onStart({url}){
console.log("Started at ", url);
}
}
export default EddieBrockApp
The studio shows 2 calls one to Options with a CORS failed
message and one to POST that says NS_ERROR_DOM_BAD_URI
I tried to add a function to explicitly set the headers...
context: ({res}) => {
res.header('test-header', 'my-header');
res.header('Vary', 'Origin');
res.header('Access-Control-Allow-Origin', 'https://studio.apollographql.com');
}
I see the headers...
But still the Apollo studio fails. I try their debug and I get...
npx [email protected] --endpoint=https://mysite.co
But I get...
⚠️ OPTIONS response returned 404. Is the url correct? Are authorization headers or cookies required?
⚠️ OPTIONS response is missing header 'access-control-allow-methods: POST'
⚠️ POST response returned 404. Is the url correct? Are authorization headers or cookies required?
⚠️ POST response missing 'access-control-allow-origin' header.
What am I doing wrong how do I avoid these CORS issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论