Submitted June 20, 2020 at 02:20AM by halsheik
Friday, 19 June 2020
CSS only applied to some paths of HTML file for Nodejs express application
I'm a beginner working on a Nodejs express application and I am having trouble getting a CSS style sheet to apply to a login and registration HTML files. This same CSS file does however apply to other files. I was wondering if anyone can take a look?Here is a link to my git repository: https://github.com/halsheik/RecipeWarehouse.git.Edit: I had the wrong app.js and _header.html file uploaded. Here is the correct file code:app.js file:```// Modules required to run the applicationconst express = require('express');const path = require('path');const mongoose = require('mongoose');const flash = require('connect-flash');const session = require('express-session');const passport = require('passport');// Creates an express applicationvar app = express();// Configconst db = require('./config/keys').MongoURI; // Database Configrequire('./config/passport')(passport); // Passport Config// Connect to Mongomongoose.connect(db, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => console.log('MongoDB connected...')).catch(err => console.log(err));// Accepts a parameter from the 'ENVIROMENT' for what// port to listen on and sends to severapp.set("port", process.env.PORT || 3000);// Sets up view engine (using 'ejs')app.set("views", path.join(__dirname, "views"));app.set("view engine", "ejs");// Bodyparser - urlencoded() is used to recognize incoming Request Object as strings or arrays// Specifically to help with POST and PUT Requrestsapp.use(express.urlencoded({ extended: false })); // 'extended' has to do with whether or not a nested object can be used ('false' means it cannot)// Express session middlewareapp.use(session({secret: 'secret',resave: true,saveUninitialized: true,}));// Passport middlewareapp.use(passport.initialize());app.use(passport.session());// Connect flashapp.use(flash());// Allows express app access to CSS and JavaScript filesapp.use(express.static(path.join(__dirname, 'public')));// Route Filesapp.use('/', require('./routes/index')); // Module containing basic paths for applicationapp.use('/users', require('./routes/users')); // Module containing paths for user login and registrationapp.listen(app.get("port"), function(){console.log(`Listening to server on port ${app.get("port")}...`);});```_header.html file:```
Homemade
```I'd appreciate any help.
Submitted June 20, 2020 at 02:20AM by halsheik
Submitted June 20, 2020 at 02:20AM by halsheik
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment