Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server-render does not work for android/cordova #9970

Closed
ayalpani opened this issue Jun 8, 2018 · 2 comments · May be fixed by awaisab172/meteor#5, awaisab172/meteor#32 or baophucct/meteor#44
Closed

server-render does not work for android/cordova #9970

ayalpani opened this issue Jun 8, 2018 · 2 comments · May be fixed by awaisab172/meteor#5, awaisab172/meteor#32 or baophucct/meteor#44

Comments

@ayalpani
Copy link
Contributor

ayalpani commented Jun 8, 2018

Hi.

Steps to reproduce:

meteor create test-server-render
cd test-server-render/
meteor add server-render
meteor add-platform android

Edit server/main.js:

import { Meteor } from 'meteor/meteor';
import { onPageLoad } from 'meteor/server-render'

Meteor.startup(() => {
    onPageLoad(sink => {
      sink.appendToBody('<span>Hello World!</span>')
      sink.appendToHead('<meta prop="hello" content="world" />')
    })
});

Then:

meteor run android-device --verbose

The web version http://localhost:3000/ in my browser shows both changes to body and head.

Unfortunately, the app on Android phone doesn't. Neither the head changes (only the boilerplate code shows up), nor the body shows "Hello World!".

--
Please help me with this issue. I already spent days solely to solve the issue of changing the boilerplate header code. I also get no responses on the meteor forum. I seem to be the only person in the world, trying to modify the boilerplate code for cordova (to achieve changes to the Content-Security-Policy meta tag).

@benjamn
Copy link
Contributor

benjamn commented Jun 8, 2018

Cordova works a bit differently from Meteor's standard webapp package. Specifically, the static boilerplate HTML is generated once, during build, rather than every time you access the app on the device. See the cordova-plugin-meteor-webapp README for more information. This means server-side rendering does not work the same way for Cordova, which is admittedly unfortunate, but that's the best answer I can give you right now.

The CSP rules for Cordova are hard-coded in boilerplate-generator/template-web.cordova.js, so a possible workaround here would be to copy the boilerplate-generator package into your app's local packages/ directory, and then modify that file as necessary. This will override any other version of the boilerplate-generator package that your app might be using.

@ayalpani
Copy link
Contributor Author

ayalpani commented Jun 8, 2018

Hi Ben,

thank you for taking the time and for the workaround proposal. I tried copying the package locally as proposed and it did work perfectly.

I love meteor, keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants