Ionic2 with Meteor - meteor

I have a problem using Meteor in an Ionic2 project.
The project itself should run, as it is a clone of the Meteor-tutorial:
git clone https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp
When I start the Meteor server I get this
=> Started proxy.
server/publications.ts (24, 10): Property 'publishComposite' does not exist on type 'typeof Meteor'.
server/main.ts (14, 28): Property '_options' does not exist on type 'typeof Accounts'.
server/main.ts (51, 14): Property 'createUserWithPhone' does not exist on type 'typeof Accounts'.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
Then I start the ionic app with ionic serve and get this in the terminal
Running live reload server: http://localhost:35729
Watching: www/**/*, !www/lib/**/*, !www/**/*.map
√ Running dev server: http://localhost:8100
When I open the App I get this error in the browser's console:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8100/sockjs/info?cb=_07sz35uj7
As I understand it means that it tries to grab data from meteor but couldn't reach it. When I open the URL in the browser manually and change the port to 3000 I get back a message from meteor.
I found two hints on Google:
1) start the ionic app without livereload
ionic serve --nolivereload
2) to set __meteor_runtime_config__ to the correct URL:PORT
But hint 1 doesn't work and for hint 2 I have no idea where to place it.
While writing this I found out, that in the file node_modules/meteor-client-side/meteor-runtime-config.js the correct port is defined by
__meteor_runtime_config__ = {};
__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = 'http://localhost:3000';
So it looks like hint 2 is also already done.
Why is it still trying to reach the meteor server on wrong port, or is there maybe another problem?

Ok, solved it on my own again.
I had to add those lines of code to the index.html file of my ionic2 project:
<script>
__meteor_runtime_config__ = {
DDP_DEFAULT_CONNECTION_URL: 'http://localhost:3000'
};
</script>
No idea, why the config in the node_modules/meteor-client-side/meteor-runtime-config.js file is ignored.
Edit: Looks like there was a bug that is fixed in version 1.3.5
https://github.com/idanwe/meteor-client-side/issues/28#issuecomment-263252756

Related

Github Probot create-probot-app: 'Cannot POST /' (404) response to webhook request

Testing out the npx create-probot-app; tried with each of the starters and the same problem exists.
I create, build, and run the app, and then configure and install the app on github, I am able to receive webhook events but I'm seeing my local app respond with a 404.
smee receives the event
error: Error: cannot POST / (404)
ERROR (server): Not Found
Error: Not Found
at Request.callback (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:884:15)
at IncomingMessage.<anonymous> (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:1127:20)
at IncomingMessage.emit (events.js:326:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
status: 404
My index.ts:
export = (app: Probot) => {
app.on("issues.opened", async (context) => {
const issueComment = context.issue({
body: "Thanks for opening this issue!",
});
await context.octokit.issues.createComment(issueComment);
});
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
};
I've checked that my environment variables appear to be setup correctly in .env
In sum, github is sending a webhook, smee is receiving it, but my local app is responding with 404: cannot post /
Not able to get the example app to process webhook events due to what appears to be a routing issue. Anyone encountered this before?
Make sure you don't have any other applications running on Port 3000. Create React App uses 3000 by default and can cause the error you are describing.
One of the possible reasons could be that your GitHub App does not have privileges to take that action. Would it be possible that your GitHub App is missing the 'issues' privilege setting? (https://docs.github.com/en/rest/reference/permissions-required-for-github-apps#permission-on-issues)

create-next-app does not work, get internal server error

Need some advice on this. I have initialize a whole new project by using create-next-app:
npx create-next-app nextjs-app
I was able to start the project by calling npm run dev. This is what i have in the terminal when run on the development server:
ready - started server on http://localhost:3000
However, i get internal server error when navigate to localhost:3000. There is this error on the terminal:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
I am running on node v12.16.3 and npm v6.14.4

Meteor - cfs-gridFS not working production server but works fine on local server

I am having issues uploading images to my meteorJs app using CollectionFS/ GridFs packages. The app works fine with image upload on my localhost but when I deploy to a production server and try to upload an image, I get a broken image, and when i visit the image url, i get this error
Error in method "/cfs/files/:value/:value/", Error: TypeError: Cannot read property 'Images' of undefined
at Object.httpGetHandler (packages/cfs_access-point/packages/cfs_access-point.js:357:1)
at Object.accessPoint.get (packages/cfs_access-point/packages/cfs_access-point.js:675:1)
at packages/cfs_http-methods/http.methods.server.api.js:581:1
I have tried several solutions like dropping the database or even deleting and creating a new server, but the result is still the same.
I am using these packages
cfs:standard-packages
cfs:gridfs
Update
Code Snippet
`//collection
postImages = new FS.Collection("postimages", {
stores: [new FS.Store.GridFS("postimages", {})]
});
//permissions
postImages.allow({
insert: function(userId, doc){return true;},
download: function(userId){return true;}
});`
Any suggestions on how to solve this?
Thanks

GraphiQL for Apollo Fine on Desktop, 404 on Laptop?

I've got GraphIQL running fine on my desktop Mac at http://localhost:8080/graphql.
And on my laptop Mac, using the exact same code synced via Github, I show this in the console:
GraphQL Server is now running on http://localhost:8080/graphql
...which appears to indicate that graphql is connected. But accessing
http://localhost:8080/graphql brings up a 404 error:
Not Found
The requested URL /graphql was not found on this server
I even deleted my node_modules folder and reinstalled from scratch via meteor npm install.
Does this make sense to anybody?
Here's the code that sets up Apollo and graphiql:
//apollo
import express from 'express';
import { apolloServer } from 'apollo-server';
import Schema from '/imports/api/schema';
import Mocks from '/imports/api/mocks';
import Resolvers from '/imports/api/resolvers';
import Connectors from '/imports/api/db-connectors';
const GRAPHQL_PORT = 8080;
const graphQLServer = express();
graphQLServer.use('/graphql', apolloServer({
graphiql: true,
schema: Schema,
resolvers: Resolvers,
connectors: Connectors,
mocks: Mocks,
}));
graphQLServer.listen(GRAPHQL_PORT, () => console.log(
`GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}/graphql`
));
So, this could be because you have something else running on 8080 on your laptop. Maybe try logging uncaught express errors to the console?
Another possibility is that you're not trying exactly the same URL on your desktop. Version 0.2 of apolloServer currently allows only POST requests. When you navigate to the address in your browser, it will try to send a GET request, which will result in a 404. Try spinning up graphiql on a separate route and see if you can access that.
PS: If you get a chance, you should make a PR to the repo where you copy-pasted the code snippet from, so other people won't run into the same issue ;-)
I used npm remove apollo-server and npm install apollo-server --save to update the apollo-server npm module, and did the same for apollo-client. I then updated to the apollo server 0.2.x code found at http://docs.apollostack.com/apollo-server/migration.html. I also updated to Meteor 1.4.x. Now the 404 error is gone.

Open files in PHPStorm with Vagrant+Symfony application

I know you can open files from Symfony profiler or exception file links using this in project/app/config.yml :
framework:
ide: "phpstorm://open?file=%%f&line=%%l"
More info: http://developer.happyr.com/open-files-in-phpstorm-from-you-symfony-application
However as I'm using vagrant, the file path of the server doesn't match my host.
I have created a PHP web application server in PHPStorm with the propper path mappings, but still doesn't work.
Any ideas?
Thanks
When running your app in a container or in a virtual machine, you can tell Symfony to map files from the guest to the host by changing their prefix. This map should be specified at the end of the URL template, using & and > as guest-to-host separators:
// /path/to/guest/.../file will be opened
// as /path/to/host/.../file on the host
// as /path/to/host/.../file on the host
'phpstorm://%f:%l&/path/to/guest/>/path/to/host/&/foo/>/bar/&...'
Symfony FrameworkBundle Configuration - IDE
The answer given by Jeffry no longer works unfortunately :(. When In configure that with my paths the profiler throws:
ParameterNotFoundException
You have requested a non-existent parameter "f:".
I have configured the path according to this line in the SF docs: This map should be specified at the end of the URL template, which results in this:
phpstorm://open?url=file://%%f&line=%%l&/path/to/guest/>/path/to/host/
However, it does open PHPStorm, but phpstorm does not open the file, so i'm a bit stuck here now.
This solves the issue with the file not opening in PhpStorm from a Vagrant:
phpstorm://open?file=%%f&line=%%l&/path/to/guest/>/path/to/host/
Source: https://youtrack.jetbrains.com/issue/IDEA-65879

Resources