Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pathname used in express initialisation #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/db/db-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ const DEFAULT_CONNECTION_STRING = `mongodb+srv://${process.env.MONGODB_USER}:${p
export default function connectToDatabase(
connectionString = DEFAULT_CONNECTION_STRING
) {
return mongoose.connect(connectionString);
return mongoose.connect(connectionString, { useNewUrlParser: true });
}
6 changes: 4 additions & 2 deletions backend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from "express";
import cors from "cors";
import { join } from "path";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
import connectToDatabase from "./db/db-connect.js";

// Setup our routes.
Expand All @@ -18,8 +19,9 @@ app.use(express.json());
app.use("/", routes);
app.use(errorHandler);

const __dirname = dirname(fileURLToPath(import.meta.url));
// Make the "public" folder available statically
app.use(express.static(join(import.meta.dirname, "../public")));
app.use(express.static(join(__dirname, "../public")));

// Serve up the frontend's "build" directory, if we're running in production mode.
if (process.env.NODE_ENV === "production") {
Expand Down
Loading