danimohamadnejad's avatar

How to let assets to be read from a location other than / in laravel?

Hi. I have a Vue+Laravel applcation. When I call "npm run watch", Mix compiles and put output in "public/app.js". Now please check following lines:


var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
___CSS_LOADER_EXPORT___.push([module.id, "\n@font-face {\n    font-family: qiri;\n    src: url(/font/qiri.ttf);\n}\nh2[data-v-79eb75d8]{\n    font-family: qiri;\n}\n", ""]);
 const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);


As you see public files such as "qiri.ttf" are being read from base "/". This works fine on localhost but when I take project to host, public path is "/public". How can I configure Mix so that it set "/public" as base path for reading public files? What I actually want is to call public files from /public instead of /

0 likes
3 replies
Sinnbeck's avatar

Why is the path on production /public? Sounds like you put your content inside the public_html or htdocs directory?

1 like
Sinnbeck's avatar

@danimohamadnejad quickly remove them! People how have full access to you env file! Instead move them inside the directory below and symlink public to public_html

@snapey is quite knowledgeable at how to do this

Please or to participate in this conversation.