These are chat archives for reactioncommerce/reaction

14th
Jul 2018
William Moss
@willmoss1000
Jul 14 2018 16:46 UTC
Hey All, trying to setup a cloudfront CDN, and viewing in localhost I'm getting: Resource interpreted as Stylesheet but transferred with MIME type text/html
Loan Laux
@loanlaux
Jul 14 2018 16:47 UTC
@willmoss1000 When you manually open that stylesheet through the CloudFront link, does it show up as it should?
William Moss
@willmoss1000
Jul 14 2018 16:49 UTC
aha! I think I need to add: BrowserPolicy.content.allowConnectOrigin( for the CDN link
Loan Laux
@loanlaux
Jul 14 2018 16:49 UTC
Yes you do :)
William Moss
@willmoss1000
Jul 14 2018 16:54 UTC
@loanlaux sorry, I've really got no idea what Im doing here! When I go to the CDN link - it should load the site?
Loan Laux
@loanlaux
Jul 14 2018 16:54 UTC
You should get the stylesheet, served through the CDN
At least that's what I understood you were trying to do, right?
Serving both the JS bundle and the CSS bundle through CloudFront, am I right?
William Moss
@willmoss1000
Jul 14 2018 16:55 UTC
Yep
using WebAppInternals.setBundledJsCssPrefix(
Loan Laux
@loanlaux
Jul 14 2018 16:55 UTC
Alright, standard setup then
William Moss
@willmoss1000
Jul 14 2018 16:55 UTC
with my CDN link, which is cloudFront
Yes, so I can't really see what I'm doing wrong!
Loan Laux
@loanlaux
Jul 14 2018 16:56 UTC
So what's the link to your stylesheet through CloudFront?
Where is it served at?
William Moss
@willmoss1000
Jul 14 2018 16:57 UTC
Does this only work with a production bundle?
it is...
Loan Laux
@loanlaux
Jul 14 2018 16:58 UTC
Yes, it only works in production
WebAppInternals.setBundledJsCssPrefix is ignored in dev mode
William Moss
@willmoss1000
Jul 14 2018 16:58 UTC
Ok, but I'm getting errors in localhost when I've included it
>
?
Loan Laux
@loanlaux
Jul 14 2018 16:59 UTC
Well, are you using --production?
William Moss
@willmoss1000
Jul 14 2018 17:00 UTC
Nope. I'm just calling reaction from the console
Loan Laux
@loanlaux
Jul 14 2018 17:01 UTC
And you're getting errors? That's strange as it really should be ignored in development
William Moss
@willmoss1000
Jul 14 2018 17:01 UTC
Does it matter that I've input the link directly to WebAppInternals.setBundledJsCssPrefix(, rather than putting it in settings? I've just created a file called "cdn.js" and placed in the server folder for now
i.e. Meteor.startup(() => WebAppInternals.setBundledJsCssPrefix("https://xxx.cloudfront.net")); // eslint-disable-line no-undef
Loan Laux
@loanlaux
Jul 14 2018 17:02 UTC
Shouldn't be a problem. Can you give me the exact setBundledJsCssPrefix code snippet with the CloudFront URL?
Got it, thanks
William Moss
@willmoss1000
Jul 14 2018 17:02 UTC
I've DM's you the URL
Loan Laux
@loanlaux
Jul 14 2018 17:02 UTC
And when you try to access https://xxx.cloudfront.net/123456789asdfghj.css in a browser tab, what do you get?
William Moss
@willmoss1000
Jul 14 2018 17:02 UTC
Thanks Loan!!!
Nothing returns, just error in console
ebSocket connection to 'wss://xxxx.cloudfront.net/sockjs/097/auty1gb3/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
Loan Laux
@loanlaux
Jul 14 2018 17:05 UTC
I got it. What's happening here is that you're basically getting a full blown Reaction 404 page, with Meteor's websocket being loaded and all.
Now, it shouldn't be an issue on localhost while in development mode. I have no idea why this would happen.
William Moss
@willmoss1000
Jul 14 2018 17:07 UTC
Nor do I haha
Loan Laux
@loanlaux
Jul 14 2018 17:07 UTC
Have you tried deploying the website on a staging environment with CloudFront set up?
William Moss
@willmoss1000
Jul 14 2018 17:07 UTC
Nope, but maybe that's what I need to do. What's weird is why it's causing me errors in localhost?
Loan Laux
@loanlaux
Jul 14 2018 17:09 UTC
You should consider flushing your .meteor/local directory (except for .meteor/local/db/) so that the project gets built from scratch
It's essentially like doing a reaction reset but without touching the database
William Moss
@willmoss1000
Jul 14 2018 17:09 UTC
No worries, I'll just reaction reset - should have same effect?
I'll give that a go...
Loan Laux
@loanlaux
Jul 14 2018 17:10 UTC
If you don't mind flushing the database then yes
William Moss
@willmoss1000
Jul 14 2018 17:18 UTC
@loanlaux no luck..
Loan Laux
@loanlaux
Jul 14 2018 17:19 UTC
What happens for that request in the network tab of your devtools?
William Moss
@willmoss1000
Jul 14 2018 17:20 UTC
It's not just for one request
It's for pretty much all my js files it looks like
Loan Laux
@loanlaux
Jul 14 2018 17:21 UTC
Can you post a screenshot?
William Moss
@willmoss1000
Jul 14 2018 17:21 UTC
sure
Loan Laux
@loanlaux
Jul 14 2018 17:22 UTC
Worst case scenario, you can simply wrap you setBundledJsCssPrefix call in a Meteor.isProduction if check
William Moss
@willmoss1000
Jul 14 2018 17:22 UTC
@loanlaux DM'd to you
Loan Laux
@loanlaux
Jul 14 2018 17:22 UTC
Even though setBundledJsCssPrefix is supposed to do that by itself
William Moss
@willmoss1000
Jul 14 2018 17:22 UTC
Aha, but this shouldn't be happening?
Loan Laux
@loanlaux
Jul 14 2018 17:22 UTC
Well then there would be no chance for it to happen at all. It's worth trying at least as a debug step.
Thanks for the screenshot, yeah this is strange but it reinforces my intuition on using Meteor.isProduction
William Moss
@willmoss1000
Jul 14 2018 17:25 UTC
Ok, I'll give that a go. Cheers!
Loan Laux
@loanlaux
Jul 14 2018 17:25 UTC
Let me know