Spaces:
Sleeping
Sleeping
// Define the basic imports and constants. | |
const express = require('express'); | |
const app = express(); | |
const embeddedApp = express(); | |
const port = 3000; | |
const embeddedPort = 3001; | |
// Setup the outside app with the www folder as static content. | |
app.use(express.static('www')); | |
// Create the outside app and run it. | |
app.listen(port, () => { | |
console.log(`Open browser to http://localhost:${port}/ to begin.`); | |
}); | |
// Create the embedded app with the www2 folder as static content and | |
// set the cookie from the embedded app in the headers on all requests. | |
embeddedApp.use(express.static('www2', { | |
setHeaders: function (res, path, stat) { | |
res.set('Set-Cookie', "embeddedCookie=Hello from an embedded third party cookie!;Path=/;Secure;SameSite=None"); | |
} | |
})); | |
// Create the server and start it. | |
embeddedApp.listen(embeddedPort, () => { | |
console.log(`Embedded server now running on ${embeddedPort}...`) | |
}); |