Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

multi level route static file not found issue in express

// Make the href or the src absolute path instead of a relative path 
// by adding / at the beginning of the path

// before - relative path
<link rel="stylesheet" href="stylesheets/style.css"> 
// dependent on which route you are visiting
// on http://localhost:3000/article/create, it will search for style.css
// in the http://localhost:3000/article/stylesheets/style.css url
// which is wrong ( not the public directory )

// after - absolute path
<link rel="stylesheet" href="./stylesheets/style.css">
// independent of which route you are visiting
// will always search for your files in the public directory
// Courtesy: Sadeen Alaa - https://stackoverflow.com/users/11689488/sadeen-alaa
Comment

PREVIOUS NEXT
Code Example
Javascript :: hover inline css 
Javascript :: what is runtime in javascript 
Javascript :: generate history logs 
Javascript :: openai giving me a 401 
Javascript :: Text with prop value is rendered The component renders variable text based on a string prop. We test that the component renders the value of the passed prop. 
Javascript :: release mouse key javascript 
Javascript :: show more vs editor shortcut key 
Javascript :: javascript capitalize every word in a string 
Javascript :: dynamic copyright year JavaScript centre aligned 
Javascript :: Javascript Reverse Words O(n) time O(1) space 
Javascript :: Use Set to ensure the uniqueness of a list of values javascript 
Javascript :: Replacing If Else Chains with Switch 
Javascript :: javascript change color of button onclick 
Javascript :: how to print message in nodjs 
Javascript :: JS equal sibling btns height 
Javascript :: decrypt javascript code 
Javascript :: validate vpa api razorpay stackoverflow 
Javascript :: JS mixin implementation 
Javascript :: vue format number as dollars 
Javascript :: python save api response to json file append 
Javascript :: js remove item on index 
Javascript :: discord.js Function to replace certain characters with a pattern 
Javascript :: React Native Component with Random Hexa 
Javascript :: javascript one linde condition 
Javascript :: Load RequireJS Script 
Javascript :: react form validation with logic boolean, string and number 
Javascript :: getters javascript 
Javascript :: slick slider on change 
Javascript :: react lifecycle 
Javascript :: move_uploaded_file equivalent in js 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =