laravel-ssr icon indicating copy to clipboard operation
laravel-ssr copied to clipboard

Issue In SSR

Open saaiful opened this issue 7 years ago • 1 comments

After building everything successfully, I started the render_server and reloaded my site and I get following error: ReferenceError: window is not defined at Object.<anonymous> (__vue_ssr_bundle__:16465:1) at __webpack_require__ (__vue_ssr_bundle__:21:30) at Object.<anonymous> (__vue_ssr_bundle__:14206:1) at __webpack_require__ (__vue_ssr_bundle__:21:30) at Object.module.exports.Object.defineProperty.value (__vue_ssr_bundle__:14134:12) at __webpack_require__ (__vue_ssr_bundle__:21:30) at __vue_ssr_bundle__:64:18 at Object.<anonymous> (__vue_ssr_bundle__:67:10) at evaluateModule (D:\wamp64\www\beezoy-ssr\node_modules\vue-server-renderer\build.js:8338:21) at D:\wamp64\www\beezoy-ssr\node_modules\vue-server-renderer\build.js:8374:17

saaiful avatar Apr 07 '18 01:04 saaiful

Hi, this is the same problem in Nuxt.js

window is not defined on node runtime, you have to check if the code is running on server or browser.

Here an example:

created(){
    if(process.browser === true){
        var array = window.Array();
        array.push("ok");
        window.arraytest = array;
    }
}

exodusanto avatar Apr 09 '18 12:04 exodusanto