Foundry and discord bot
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s
This commit is contained in:
@@ -40,13 +40,34 @@ require('./services/passport')(passport);
|
||||
// CORS
|
||||
app.use(cookieParser());
|
||||
|
||||
app.use(cors({
|
||||
const foundryCorsPaths = [
|
||||
'/api/foundry/link/complete', '/foundry/link/complete',
|
||||
'/api/foundry/sync', '/foundry/sync',
|
||||
];
|
||||
const foundryCors = cors({
|
||||
origin: true,
|
||||
methods: ['GET', 'POST', 'OPTIONS'],
|
||||
allowedHeaders: ['Authorization', 'Content-Type'],
|
||||
});
|
||||
app.use('/api/foundry/link/complete', foundryCors);
|
||||
app.use('/foundry/link/complete', foundryCors);
|
||||
app.use('/api/foundry/sync', foundryCors);
|
||||
app.use('/foundry/sync', foundryCors);
|
||||
|
||||
const appCors = cors({
|
||||
origin: 'http://localhost:3000',
|
||||
credentials: true, // if using cookies/auth
|
||||
}));
|
||||
});
|
||||
app.use((req, res, next) => {
|
||||
if (foundryCorsPaths.some((path) => req.path === path || req.path.startsWith(`${path}/`))) return next();
|
||||
appCors(req, res, next);
|
||||
});
|
||||
|
||||
// ROUTES (NO AUTH)
|
||||
app.use('/api/user', require('./routes/user'));
|
||||
app.use('/api/discord', require('./routes/discord'));
|
||||
app.use('/api/foundry', require('./routes/foundry-link'));
|
||||
app.use('/foundry', require('./routes/foundry-link'));
|
||||
|
||||
// AUTH
|
||||
checkAuth = passport.authenticate('jwt', { session: false });
|
||||
@@ -56,6 +77,9 @@ app.use(checkAuth);
|
||||
app.use('/api/campaign', require('./routes/campaign'));
|
||||
app.use('/api/note', require('./routes/note'));
|
||||
app.use('/api/folder', require('./routes/folder'));
|
||||
app.use('/api/actor', require('./routes/actor'));
|
||||
app.use('/api/item', require('./routes/item'));
|
||||
app.use('/api/foundry', require('./routes/foundry'));
|
||||
/*
|
||||
app.use('/campaign', require('./routes/campaign'));
|
||||
app.use('/maps', require('./routes/map'));
|
||||
@@ -70,4 +94,4 @@ app.get("/api/test", (req, res) => {
|
||||
|
||||
app.listen(5000, () => {
|
||||
console.log("Server running on port 5000");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user