Skip to content

Commit

Permalink
Merge pull request #3 from Opetushallitus/prettier
Browse files Browse the repository at this point in the history
Prettier
  • Loading branch information
pretseli authored Apr 17, 2024
2 parents e193756 + 51052ab commit b004632
Show file tree
Hide file tree
Showing 34 changed files with 1,760 additions and 414 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "prettier"]
}
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./node_modules/.bin/lint-staged
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
30 changes: 15 additions & 15 deletions dev-server.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import next from "next";
import { parse } from "url";
import { createServer } from "https";
import fs from "fs";
import { createProxyMiddleware } from "http-proxy-middleware";
import nextConfig from './next.config.mjs'
import next from 'next';
import { parse } from 'url';
import { createServer } from 'https';
import fs from 'fs';
import { createProxyMiddleware } from 'http-proxy-middleware';
import nextConfig from './next.config.mjs';

const basePath = nextConfig.basePath;
const port = parseInt(process.env.PORT, 10) || 3404;
Expand All @@ -13,43 +13,43 @@ const virkailijaOrigin = process.env.VIRKAILIJA_URL;
const app = next({
conf: nextConfig,
dev: true,
hostname: "localhost",
hostname: 'localhost',
port: port,
env: process.env
env: process.env,
});

const handle = app.getRequestHandler();

const proxy = createProxyMiddleware({
autoRewrite: true,
headers: {
"Access-Control-Allow-Origin": virkailijaOrigin,
'Access-Control-Allow-Origin': virkailijaOrigin,
},
changeOrigin: true,
cookieDomainRewrite: "localhost",
cookieDomainRewrite: 'localhost',
secure: false,
target: virkailijaOrigin,
});

const httpsOptions = {
key: fs.readFileSync("./certificates/localhost-key.pem"),
cert: fs.readFileSync("./certificates/localhost.pem"),
key: fs.readFileSync('./certificates/localhost-key.pem'),
cert: fs.readFileSync('./certificates/localhost.pem'),
};

app.prepare().then(() => {
createServer(httpsOptions, (req, res) => {
const parsedUrl = parse(req.url, true);
const { pathname } = parsedUrl;
if (!pathname || pathname === "" || pathname === "/") {
if (!pathname || pathname === '' || pathname === '/') {
res.writeHead(302, { Location: basePath });
res.end()
res.end();
} else if (pathname.startsWith(basePath)) {
handle(req, res, parsedUrl);
} else {
proxy(req, res);
}
}).listen(port, (err) => {
if (err) throw err;
console.log("ready - started server on url: https://localhost:" + port);
console.log('ready - started server on url: https://localhost:' + port);
});
});
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */

const basePath = "/valintojen-toteuttaminen"
const basePath = '/valintojen-toteuttaminen';

const nextConfig = {
basePath,
Expand Down
Loading

0 comments on commit b004632

Please sign in to comment.