Tag: codegen

CORS问题使用生成的代码(SWAGGER)

我生成我的服务器代码( nodejs-server )基于我有的规格说明。 问题是,当我尝试从我的用户界面(不同的域)击中API时,我得到了知道CORS未启用的错误: XMLHttpRequest cannot load http://127.0.0.1:10010/events. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. 我生成的index.js如下所示: 'use strict'; var fs = require('fs'), path = require('path'), http = require('http'); var app = require('connect')(); var swaggerTools = require('swagger-tools'); var jsyaml = require('js-yaml'); var serverPort = 10010; // swaggerRouter […]