Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Sub-routes in Main route not getting static files ExpressJS

// 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 :: threee.js camera to point 
Javascript :: Caused by: PG::ConnectionBad: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? postgres app 
Javascript :: node_modules edux-sagaesindex.js 
Javascript :: three.js first issue resolved awwwards merge webgl html worlds 
Javascript :: shopify a problem repeatedly occured on url 
Javascript :: how to refrence schema in my mongoose schema with populate function 
Javascript :: javascript promise multi function error 
Javascript :: express.js 
Javascript :: how to jump one page to another on specific tab elementor 
Javascript :: detect paste in textarea 
Javascript :: Scotch.io - Create a CRUD App with Node and MongoDB 1 Getting Started 
Javascript :: react clikc with ref 
Javascript :: top 50 mcq que in javascript 
Javascript :: cookies in electron 
Javascript :: react router v6 wrapped routes in separate files 
Javascript :: To disable server-to-server and REST tools like Postman to access our API - Remove !origin from your if statement. 
Javascript :: jsx expressions 
Javascript :: javascript find in array cannot read property of undefined 
Javascript :: cypress json no videos 
Javascript :: Using JSON As Parameter 
Javascript :: element non empty jquer y check 
Javascript :: Below Means Person is A Constructor Function 
Javascript :: store in memory an array (two-dimensional) 10rows x 10columns with random integers and show the number of elements between 10 and 20 javvascript 
Javascript :: invalid json text mysql 
Javascript :: find result using type: mongoose.Schema.ObjectId, 
Javascript :: change jquery to javascript 
Javascript :: add item or nothing array js 
Javascript :: math min js 
Javascript :: highest value of x and y in javascript 
Javascript :: react native avoid keyboard when multiline 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =