{"id":11323,"date":"2020-02-28T11:58:23","date_gmt":"2020-02-28T11:58:23","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=11323"},"modified":"2021-11-12T06:47:08","modified_gmt":"2021-11-12T06:47:08","slug":"error-access-css-js-file-in-local-and-laravel-development-server-both","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/error-access-css-js-file-in-local-and-laravel-development-server-both\/","title":{"rendered":"[SOLVED] Error: Access CSS\/js file in Local and Laravel-development Server both."},"content":{"rendered":"\n<p>In Laravel, our all assets are in the <em><strong>public<\/strong><\/em> directory, But it gives error while we run Same code in <em>Laravel development server<\/em> and <em>Local Server<\/em>. See below how <\/p>\n\n\n\n<p>If we are running a <em>Laravel development server<\/em> then to access the CSS\/JS file we need to write only <strong><em>css\/layout.css<\/em><\/strong>. But if we run the similar code in <em>Local server<\/em> it shows <strong><em>error<\/em><\/strong>. <br>and, when we are running a <em>Local server<\/em>,  we need to write <strong><em>public\/css\/layout.css<\/em><\/strong> to access the CSS\/JS file. But if we run a similar code in <em>Laravel development server<\/em> it shows <strong><em>error<\/em><\/strong>.  <\/p>\n\n\n\n<p>So, what should we do to run the code on both <strong><em>Servers<\/em><\/strong>? <\/p>\n\n\n\n<p>We write the below code to Access our CSS\/JS file:-<\/p>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\"><strong><em>{{asset(&#8216;_Our-CSS\/JS-file-path_&#8217;)}}<\/em><\/strong><\/h2>\n\n\n\n<p>See the Below image of my code:- <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"740\" height=\"321\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Error-in-assets.png\" alt=\"\" class=\"wp-image-11336\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Error-in-assets.png 740w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/Error-in-assets-300x130.png 300w\" sizes=\"auto, (max-width: 740px) 100vw, 740px\" \/><\/figure><\/div>\n\n\n\n<p>After adding the above code you are able to run your code in both the Servers ( <em>Laravel development server<\/em> and <em>Local Server<\/em> ).<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_69643\"><iframe loading=\"lazy\"  id=\"_ytid_44540\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_69643\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Laravel, our all assets are in the public directory, But it gives error while we run Same code in Laravel development server and Local Server. See below how If&#8230; <\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[5203],"class_list":["post-11323","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=11323"}],"version-history":[{"count":18,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11323\/revisions"}],"predecessor-version":[{"id":24904,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/11323\/revisions\/24904"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=11323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=11323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=11323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}