微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apollo 独立服务器与 Azure 简易身份验证提示 CORS 问题

如何解决Apollo 独立服务器与 Azure 简易身份验证提示 CORS 问题

我在 Azure 应用程序服务中运行 Apollo 独立服务器并使用简单的身份验证(Azure Active Directory),但在重定向回 graphql 游乐场页面后出现 CORS 问题。

任何帮助都会很棒。

错误信息:

访问“https://login.windows.net/96060fbd-bc66-4ff6-9878-8865580ffd2d/oauth2/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Fmyapp.net%azurewebsites” 2F.auth%2Flogin%2Faad%2Fcallback&CLIENT_ID = 150c8b93-7a67-43bb-b8a9-4aa0b959a45b&范围= +的OpenID轮廓+电子邮件&response_mode = form_post&随机数= 4b68ae31662f4db79b5e0e7599842ae8_20210306002029&状态=再导向%3D%252F '(从重定向' https://myapp.azurewebsites.net/ ') from origin 'https://myapp.azurewebsites.net' 已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:请求中不存在“Access-Control-Allow-Origin”标头资源。如果不透明响应满足您的需求,请将请求的模式设置为“no-cors”以在禁用 CORS 的情况下获取资源。 httpLink.js:83 GET https://login.windows.net/96060fbd-bc66-4ff6-9878-8865580ffd2d/oauth2/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Fmyapp.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback&client_id=150c8b93-7a67-43bb-b8a9-4aa0b959a45b&scope=openid+profile+email&response_mode=form_post&nonce=4b68ae31662f4db79b5e0e7599842ae8_20210306002029&state=redir%3D%252F net::ERR_Failed

包版本

"apollo-server": "^2.21.0","graphql": "^15.5.0"

const { ApolloServer,gql } = require('apollo-server');

// Construct a schema,using GraphQL schema language
const typeDefs = gql`
  type Query {
    announcement: String
  }
`;

// Provide resolver functions for your schema fields
const resolvers = {
  Query: {
    announcement: () =>
      `Say hello to the new Apollo Server! A production ready GraphQL server with an incredible getting started experience.`
  }
};

const server = new ApolloServer({ typeDefs,resolvers,playground: true,introspection: true});

server.listen(process.env.PORT || 1337).then(({ url }) => {
  console.log(`? Server ready at ${url}`);
});

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。