Load HTML file from remote
Question
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)
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
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,
},
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: {}, }
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1059
[Question]: Load html content from a file dynamically
Hi, I need to load content from a html file from server onto editor after or while initializing editor. How this can be implemented? HTML w...
Issue #597
storageManager: Loading from remote storage
Hi, I'm trying to read the HTML and CSS from my database. When I try to load it into the editor, nothing displays. I can store the data jus...
Issue #1242
[FEATURE REQUEST]: JSON to HTML parsing
Is there any support for JSON to HTML rendering, so that we can get control over the content to be published in the newsletter or webpage....
Issue #537
Adding a request header on beforeSend
Im using storageManager remote but the site has csrf token beforeSend: function (t) { var token = $('meta[name="csrf_token"]').attr('conten...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.