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

CAS-login ja autentikoidut pyynnöt clientissa #2

Merged
merged 14 commits into from
Apr 16, 2024
Merged
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VIRKAILIJA_URL=https://virkailija.testiopintopolku.fi
15 changes: 11 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Run lint
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Run unit tests
Expand All @@ -36,13 +36,20 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: install mkcert
run: |
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
- name: Create dev certificates
run: npm run create-dev-certs
- name: Start the app
run: npm run dev &
run: npm run dev-test &
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ next-env.d.ts
/playwright-report/
/blob-report/
/playwright/.cache/

certificates
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
55 changes: 55 additions & 0 deletions dev-server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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;

const virkailijaOrigin = process.env.VIRKAILIJA_URL;

const app = next({
conf: nextConfig,
dev: true,
hostname: "localhost",
port: port,
env: process.env
});

const handle = app.getRequestHandler();

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

const httpsOptions = {
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 === "/") {
res.writeHead(302, { Location: basePath });
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);
});
});
10 changes: 9 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

const basePath = "/valintojen-toteuttaminen"

const nextConfig = {
basePath,
env: {
basePath,
},
};

export default nextConfig;
Loading
Loading