Issue #2605Opened February 27, 2020by alesub0 reactions

[BUG] Getting a 404 on mixins.js

Question

First of all, thank you for this great tool.

  1. I'm using the latest version.
  2. The bug happens with a local copy of GrapesJS.
    1. MacOS - latest Chrome browser
    2. The bug is not present on the demo
  3. Expected behavior: have the editor loading without any errors
  4. What happens instead: I get a 404 error when the editor is appending styles

I'm getting the following error on the console after the editor is started: mixins.js:27 GET http://example.com/editor/null net::ERR_ABORTED 404 (Not Found) I replaced the real domain with "example.com", the rest of the URL is real.

On mixins.js, line 27, the instruction is head.insertBefore(link, head.firstChild);, it's part of the function that append styles to the editor. The problem is I'm passing an array of valid URLs, all of them resolve correctly as I see each style applied to the editor's html.

Here's how I'm creating the editor:

var editorSettings = {
	fromElement: true,
	height: '900px',
	width: '600px',
	cssIcons: null,
	storageManager: { type: null },
	noticeOnUnload: false,
	panels: { defaults: [] },
	canvas: {
		styles: [
			'https://fonts.googleapis.com/css?family=Libre+Franklin:400,600,700&display=swap',
			'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css',
			'/wp-content/plugins/votersguide/public/css/pageTemplate.css?version=1.0.26'
		]
	},
	assetManager: {
		storageType  	: '',
		storeOnChange  : true,
		storeAfterUpload  : true,
		assets    	: [],
		uploadFile: function(e) {
			var postHash = getUrlVars()['g'];
			var nonce = $('#wpNonce').val();
			var files = e.dataTransfer ? e.dataTransfer.files : e.target.files;
			var formData = new FormData();
			for(var i in files){
				formData.append('file-'+i, files[i]) //containing all the selected images from local
			}
			formData.append('action', 'votersguide_editor');
			formData.append('g', postHash);
			formData.append('nonce', nonce);

			$.ajax({
				url: myAjax.ajaxurl,
				type: 'POST',
				data: formData,
				contentType: false,
				crossDomain: true,
				dataType: 'json',
				mimeType: "multipart/form-data",
				processData:false,
				success: function(result){
					var myJSON = [];
					$.each( result['data'], function( key, value ) {
						myJSON[key] = value;
					});
					var images = myJSON;
					editor.AssetManager.add(images); //adding images to asset manager of GrapesJS
				}
			});
		},
	},
};

editorSettings.container = '#'+selectedPage.attr('id');

var editor = grapesjs.init(editorSettings);

Answers (2)

artfMarch 2, 20200 reactions

I think it's coming from cssIcons, seems like I forgot to check the value somewhere

alesubMarch 2, 20200 reactions

Amazing, looking forward for the next release! Thanks!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.