Issue #2073Opened June 10, 2019by AlejandroSuarezA0 reactions

[QUESTIONS] Trouble using urlLoad

Question

I've got an issue calling to my endpoint to load a template, it's doing a pre flight OPTIONS request but I cant find how to continue after the OK response

Code SnippetTEXT
componentDidMount() {
        this.editor = GrapesJS.init({
            container: '#grapeEditor',
            plugins: [gjsPresetNewsletter],

            storageManager: {
                id: 'gjs-',
                type: 'remote',
                urlLoad: 'http://localhost:9999/templateEndpoint',
                urlStore: 'http://localhost:9999/templateEndpoint',
                contentTypeJson: true
            }
        });
    }

    componentDidUpdate() {
        this.editor.load(e => console.log(e))
    }


This is my express server

    app.all('*', function (req, res, next) {


        res.header('Access-Control-Allow-Origin', '*');
        res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
        res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

        if (req.method == 'OPTIONS' || req.path.indexOf('favicon.ico') >= 0) {
            console.log('options method... lets pass...');
            res.sendStatus(200);
        }
        else {
            next();
        }


    });

![image](https://user-images.githubusercontent.com/22684283/59199300-ecc17480-8b95-11e9-80c6-4071032685f8.png)

Answers (3)

verdvermJune 13, 20190 reactions

Is there more to you server? Does next() actually reach a handler? Can you get the expected template from outside of 🍇 (with curl or postman)?

artfJune 15, 20190 reactions

Try to check errors in console, probably you miss something in your CORS configuration. Try to start only with res.header('Access-Control-Allow-Origin', '*'); BTW I close this as it's not related to grapesjs itself

lock[bot]June 25, 20200 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.