Browse Source

fix(nocodb): include ncSiteUrl / ncPublicUrl

pull/5042/head
Wing-Kam Wong 2 years ago
parent
commit
49c09d2b2b
  1. 4
      packages/nocodb/src/lib/meta/api/swagger/redocHtml.ts
  2. 22
      packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts
  3. 8
      packages/nocodb/src/lib/meta/api/swagger/swaggerHtml.ts
  4. 12
      packages/nocodb/src/lib/meta/api/userApi/ui/auth/emailVerify.ts
  5. 12
      packages/nocodb/src/lib/meta/api/userApi/ui/auth/resetPassword.ts
  6. 1
      packages/nocodb/src/lib/meta/api/userApi/userApis.ts
  7. 4
      packages/nocodb/src/lib/v1-legacy/gql/GqlAuthResolver.ts
  8. 4
      packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts
  9. 12
      packages/nocodb/src/lib/v1-legacy/rest/ui/auth/emailVerify.ts
  10. 12
      packages/nocodb/src/lib/v1-legacy/rest/ui/auth/resetPassword.ts
  11. 12
      packages/nocodb/src/lib/v1-legacy/rest/ui/auth/signin.ts
  12. 12
      packages/nocodb/src/lib/v1-legacy/rest/ui/auth/signup.ts
  13. 6
      packages/nocodb/src/lib/v1-legacy/rest/ui/auth/swagger.ts

4
packages/nocodb/src/lib/meta/api/swagger/redocHtml.ts

@ -1,11 +1,11 @@
export default `<!DOCTYPE html>
export default (ncSiteUrl: string): string => `<!DOCTYPE html>
<html>
<head>
<title>NocoDB API Documentation</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/css/fonts.montserrat.css" rel="stylesheet">
<link href="${ncSiteUrl}/css/fonts.montserrat.css" rel="stylesheet">
<!--
Redoc doesn't change outer page styles
-->

22
packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts

@ -5,8 +5,8 @@ import Model from '../../../models/Model';
import ncMetaAclMw from '../../helpers/ncMetaAclMw';
import getSwaggerJSON from './helpers/getSwaggerJSON';
import Project from '../../../models/Project';
import swaggerHtml from './swaggerHtml';
import redocHtml from './redocHtml';
import getSwaggerHtml from './swaggerHtml';
import getRedocHtml from './redocHtml';
async function swaggerJson(req, res) {
const project = await Project.get(req.params.projectId);
@ -38,6 +38,14 @@ async function swaggerJson(req, res) {
res.json(swagger);
}
function swaggerHtml(req, res) {
res.send(getSwaggerHtml(req.ncSiteUrl));
}
function redocHtml(req, res) {
res.send(getRedocHtml(req.ncSiteUrl));
}
const router = Router({ mergeParams: true });
// todo: auth
@ -45,11 +53,9 @@ router.get(
'/api/v1/db/meta/projects/:projectId/swagger.json',
ncMetaAclMw(swaggerJson, 'swaggerJson')
);
router.get('/api/v1/db/meta/projects/:projectId/swagger', (_req, res) =>
res.send(swaggerHtml)
);
router.get('/api/v1/db/meta/projects/:projectId/redoc', (_req, res) =>
res.send(redocHtml)
);
router.get('/api/v1/db/meta/projects/:projectId/swagger', swaggerHtml);
router.get('/api/v1/db/meta/projects/:projectId/redoc', redocHtml);
export default router;

8
packages/nocodb/src/lib/meta/api/swagger/swaggerHtml.ts

@ -1,11 +1,11 @@
export default `<!DOCTYPE html>
export default (ncSiteUrl: string): string => `<!DOCTYPE html>
<html>
<head>
<title>NocoDB : API Docs</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="/css/swagger-ui-bundle.4.5.2.min.css"/>
<script src="/js/swagger-ui-bundle.4.5.2.min.js"></script>
<link rel="shortcut icon" href="${ncSiteUrl}/favicon.ico" />
<link rel="stylesheet" href="${ncSiteUrl}/css/swagger-ui-bundle.4.5.2.min.css"/>
<script src="${ncSiteUrl}/js/swagger-ui-bundle.4.5.2.min.js"></script>
</head>
<body>
<div id="app"></div>

12
packages/nocodb/src/lib/meta/api/userApi/ui/auth/emailVerify.ts

@ -3,10 +3,10 @@ export default `<!DOCTYPE html>
<head>
<title>NocoDB - Verify Email</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.2.6.14.min.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.2.6.14.min.js"></script>
</head>
<body>
<div id="app">
@ -31,8 +31,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

12
packages/nocodb/src/lib/meta/api/userApi/ui/auth/resetPassword.ts

@ -3,10 +3,10 @@ export default `<!DOCTYPE html>
<head>
<title>NocoDB - Reset Password</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.2.6.14.min.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.2.6.14.min.js"></script>
</head>
<body>
<div id="app">
@ -58,8 +58,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

1
packages/nocodb/src/lib/meta/api/userApi/userApis.ts

@ -511,6 +511,7 @@ async function renderPasswordReset(req, res): Promise<any> {
try {
res.send(
ejs.render((await import('./ui/auth/resetPassword')).default, {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
token: JSON.stringify(req.params.tokenId),
baseUrl: `/`,
})

4
packages/nocodb/src/lib/v1-legacy/gql/GqlAuthResolver.ts

@ -85,12 +85,14 @@ export default class GqlAuthResolver {
this.app.router.get('/password/reset/:token', function (req, res) {
res.render(__dirname + '/auth/resetPassword', {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
token: JSON.stringify(req.params?.token),
baseUrl: `/api/${apiPrefix}/`,
});
});
this.app.router.get('/email/verify/:token', function (req, res) {
res.render(__dirname + '/auth/emailVerify', {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
token: JSON.stringify(req.params?.token),
baseUrl: `/api/${apiPrefix}/`,
});
@ -98,12 +100,14 @@ export default class GqlAuthResolver {
this.app.router.get('/signin', function (_req, res) {
res.render(__dirname + '/auth/signin', {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
baseUrl: `/api/${apiPrefix}/`,
});
});
this.app.router.get('/signup', function (_req, res) {
res.render(__dirname + '/auth/signup', {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
baseUrl: `/api/${apiPrefix}/`,
});
});

4
packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts

@ -138,6 +138,7 @@ export default class RestAuthCtrl {
this.app.router.get('/password/reset/:token', async function (req, res) {
res.send(
ejs.render((await import('./ui/auth/resetPassword')).default, {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
token: JSON.stringify(req.params?.token),
baseUrl: `/`,
})
@ -146,6 +147,7 @@ export default class RestAuthCtrl {
this.app.router.get('/email/verify/:token', async (req, res) => {
res.send(
ejs.render((await import('./ui/auth/emailVerify')).default, {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
token: JSON.stringify(req.params?.token),
baseUrl: `/`,
})
@ -155,6 +157,7 @@ export default class RestAuthCtrl {
this.app.router.get('/signin', async (_req, res) => {
res.send(
ejs.render((await import('./ui/auth/signin')).default, {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
baseUrl: `/`,
})
);
@ -163,6 +166,7 @@ export default class RestAuthCtrl {
this.app.router.get('/signup', async (_req, res) => {
res.render(
ejs.render((await import('./ui/auth/signup')).default, {
ncPublicUrl: process.env.NC_PUBLIC_URL || '',
baseUrl: `/`,
})
);

12
packages/nocodb/src/lib/v1-legacy/rest/ui/auth/emailVerify.ts

@ -2,10 +2,10 @@ export default `<!DOCTYPE html>
<html>
<head>
<title>NocoDB - Verify Email</title>
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.2.6.14.min.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.2.6.14.min.js"></script>
</head>
<body>
<div id="app">
@ -30,8 +30,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

12
packages/nocodb/src/lib/v1-legacy/rest/ui/auth/resetPassword.ts

@ -3,10 +3,10 @@ export default `<!DOCTYPE html>
<head>
<title>NocoDB - Reset Password</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.2.6.14.min.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.2.6.14.min.js"></script>
</head>
<body>
<div id="app">
@ -58,8 +58,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

12
packages/nocodb/src/lib/v1-legacy/rest/ui/auth/signin.ts

@ -3,10 +3,10 @@ export default `<!DOCTYPE html>
<head>
<title>NocoDB - Sign In</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.global.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.global.js"></script>
</head>
<body>
<div id="app">
@ -56,8 +56,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

12
packages/nocodb/src/lib/v1-legacy/rest/ui/auth/signup.ts

@ -3,10 +3,10 @@ export default `<!DOCTYPE html>
<head>
<title>NocoDB - Sign Up</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link href="/css/fonts.roboto.css" rel="stylesheet">
<link href="/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="/js/vue.global.js"></script>
<link href="<%- ncPublicUrl %>/css/fonts.roboto.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/materialdesignicons.5.x.min.css" rel="stylesheet">
<link href="<%- ncPublicUrl %>/css/vuetify.2.x.min.css" rel="stylesheet">
<script src="<%- ncPublicUrl %>/js/vue.global.js"></script>
</head>
<body>
<div id="app">
@ -72,8 +72,8 @@ export default `<!DOCTYPE html>
</v-container>
</v-app>
</div>
<script src="/js/vuetify.2.x.min.js"></script>
<script src="/js/axios.0.19.2.min.js"></script>
<script src="<%- ncPublicUrl %>/js/vuetify.2.x.min.js"></script>
<script src="<%- ncPublicUrl %>/js/axios.0.19.2.min.js"></script>
<script>
var app = new Vue({

6
packages/nocodb/src/lib/v1-legacy/rest/ui/auth/swagger.ts

@ -2,9 +2,9 @@ export default `<!DOCTYPE html>
<html>
<head>
<title>API Docs</title>
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="/css/swagger-ui-bundle.4.5.2.min.css"/>
<script src="/js/swagger-ui-bundle.4.5.2.min.js"></script>
<link rel="shortcut icon" href="<%- ncPublicUrl %>/favicon.ico" />
<link rel="stylesheet" href="<%- ncPublicUrl %>/css/swagger-ui-bundle.4.5.2.min.css"/>
<script src="<%- ncPublicUrl %>/js/swagger-ui-bundle.4.5.2.min.js"></script>
</head>
<body>
<div id="app">

Loading…
Cancel
Save