因此,我要迁移到apollo-server-express 2.3.3(我使用的是1.3.6),我遵循了一些指南,进行了必要的调整,但陷入了CORS问题。
根据文档,您必须使用applyMiddleware函数通过express连接apollo服务器。
我目前正在执行以下操作:
const app = express();
// CORS configuration
const corsOptions = {
origin: 'http://localhost:3000',
credentials: true
}
app.use(cors(corsOptions))
// Setup JWT authentication middleware
app.use(async (req, res, next) => {
const token = req.headers['authorization'];
if(token !== "null"){
try {
const currentUser = await jwt.verify(token, process.env.SECRET)
req.currentUser = currentUser
} catch(e) {
console.error(e);
}
}
next();
});
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({ Property, User, currentUser: req.currentUser })
});
server.applyMiddleware({ …Run Code Online (Sandbox Code Playgroud) 所以我目前使用 UglifyJsPlugin 的 drop_console 选项设置为 true,这意味着在压缩期间所有 console.* 调用都将被删除。
我现在需要保留某些 console.log 调用,但还没有真正找到可以用来完成此操作的任何内容。
有什么办法、任何命令或任何选项可以用来保留其中的一些?
一个想法可能是只保留 console.info 调用,例如,放弃 console.* 调用的其余部分,但我又不确定这是否可能。
非常感谢。
我的老师要求班级修复这个程序中的错误.实际上它似乎是一个糟糕的程序; 我只是在工作表中输入它的确切方式,并得到了这个错误:
那么现在我只是改变了一些东西,但在运行时得到这个异常:Microsoft C++异常:[rethrow]在内存位置0x00000000 ..
代码现在是这样的:(变量一个类名现在是西班牙语,抱歉为此带来不便)
#include <iostream>
#include <exception>
#include <stack>
using namespace std;
class EPilaVacia : public exception{
public:
const char* what() const throw(){
return "Error: Pila Vacía";
}
};
template <class T, int max=100>
class Pila{
private:
stack<T*> *pila;
int cont;
public:
Pila() : cont(0){
pila=new stack<T*>();
}
virtual void apilar( T* pt){
if(cont<max){
pila->push(pt); //respuesta 2
}
}
virtual void apilar(T t){
if(cont<max){
pila->push(&t); //respuesta 3
}
}
T tope() const throw (EPilaVacia){
if(cont>0){
pila->top(); //respuesta …Run Code Online (Sandbox Code Playgroud)