Reputation: 101
Trying to set the rawConnectHandlers property, I get an error message. The code is the following:
import {WebApp} from 'meteor/webapp';
WebApp.rawConnectHandlers.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
return next();
});
Although I have installed the meteor package webapp and it is listed in meteors packages file ([email protected]). I am getting the message "Cannot find module 'meteor/webapp'"
The file is called main.ts and is located directly in meteors server directory. Of course I have tried to restart the application after installing the webapp module via 'meteor add webapp' and also 'meteor add [email protected]'.
What am I doing wrong?
Upvotes: 2
Views: 1166
Reputation: 369
Seems like you're using Typescript (as I do), however Meteor Webapp doesn't have Typings yet ready (hope soon), only basic module Meteor, which you can find here https://atmospherejs.com/barbatus/typescript.
That doesn't mean that you can't use it, however you will see warnings. You can remove this warnings by declare the WebApp variable in a global scope:
declare let WebApp: any;
If you will find new Typings for Meteor, please let me know.
Upvotes: 1
Reputation: 773
webapp is usually part of the meteor base and is already installed when meteor create is called. did you try the below as in the meteor docs, there is no 'raw' its only connectHandlers.
WebApp.connectHandlers.use("/hello", function(req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
return next();
});
Please see this link https://docs.meteor.com/packages/webapp.html
Upvotes: 1
Reputation: 2245
Is it preset in your node_modules
directory?
If so, did you include it in your systemjs.config.js
?
Upvotes: 0