Issue #1431Opened September 17, 2018by mrajeshkrossark3 reactions

Load HTML file from remote

Question

Code SnippetTEXT
I hosted my html content in cloud. Then trying to load the html content in the editor I found the error:  "**Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.**"

My code: const editor = () => grapesjs.init({
    container: '#editor-portal',
    canvas: {
        styles: ['https://codepen.io/mrajeshkrossark/pen/mGLyJX.css']
    },
    plugins: ['gjs-preset-webpage'],
    pluginsOpts: {
		"gjs-components":[]
	},
    storageManager: {
        type: 'remote',
        storeHtml: true,
        storeCss: true,
        urlStore: "http://www.lightblue.byethost4.com",
        urlLoad: "http://www.lightblue.byethost4.com",
        params: {},
    }
});

Note: I wrapped the grapesjs editor into react application.

Answers (3)

JulyanoFSeptember 17, 20181 reactions

You're pointing your storage manager to a website. You need endpoints that can handle the requests. https://grapesjs.com/docs/modules/Storage.html#setup-remote-storage

I tried with below endpoints that also shows error storageManager: { type: 'remote', storeHtml: true, storeCss: true, contentTypeHTML: true, urlStore: "http://www.lightblue.byethost4.com/index.html", urlLoad: "http://www.lightblue.byethost4.com/index.html", params: {}, }

I use a json content and it is working:

storageManager: {
        autosave: true,
        setStepsBeforeSave: 2,
        type: 'remote',
        urlStore: 'comunicados/store' + id,
        urlLoad: 'comunicados/load' + id,,
        contentTypeJson: true,
    },

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.