mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 23:44:08 +00:00
fix missing images on index.html
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
9ed11a6682
commit
1a097abcf5
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@ -14,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body lang="en">
|
<body lang="en">
|
||||||
<section class="wrapper">
|
<section class="wrapper">
|
||||||
<h1><img class="logo" src="https://strapi.io/assets/images/logo_login.png" /></h1>
|
<h1><img class="logo" src="<%= strapi.config.server.url %>/assets/images/logo_login.png" /></h1>
|
||||||
<% if (strapi.config.environment === 'development' && isInitialised) { %>
|
<% if (strapi.config.environment === 'development' && isInitialised) { %>
|
||||||
<div class="informations">
|
<div class="informations">
|
||||||
<div>
|
<div>
|
||||||
@ -34,9 +34,9 @@
|
|||||||
<p>To discover the power provided by Strapi, you need to create an administrator.</p>
|
<p>To discover the power provided by Strapi, you need to create an administrator.</p>
|
||||||
<a class="cta cta-secondary" href="<%= strapi.config.admin.url %>" target="_blank" title="Click to create the first administration" ><i class="fas fa-external-link-alt"></i>Create the first administrator</a>
|
<a class="cta cta-secondary" href="<%= strapi.config.admin.url %>" target="_blank" title="Click to create the first administration" ><i class="fas fa-external-link-alt"></i>Create the first administrator</a>
|
||||||
<div class="people-saying-hello">
|
<div class="people-saying-hello">
|
||||||
<img class="visible" src="https://strapi.io/assets/images/group_people_1.png" alt="People saying hello" />
|
<img class="visible" src="<%= strapi.config.server.url %>/assets/images/group_people_1.png" alt="People saying hello" />
|
||||||
<img src="https://strapi.io/assets/images/group_people_2.png" alt="People saying hello" />
|
<img src="<%= strapi.config.server.url %>/assets/images/group_people_2.png" alt="People saying hello" />
|
||||||
<img src="https://strapi.io/assets/images/group_people_3.png" alt="People saying hello" />
|
<img src="<%= strapi.config.server.url %>/assets/images/group_people_3.png" alt="People saying hello" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const path = require('path');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const koaStatic = require('koa-static');
|
const koaStatic = require('koa-static');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
const serveStatic = require('./serve-static');
|
||||||
|
|
||||||
const utils = require('../../utils');
|
const utils = require('../../utils');
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ module.exports = strapi => {
|
|||||||
'config.info.version',
|
'config.info.version',
|
||||||
'config.info.name',
|
'config.info.name',
|
||||||
'config.admin.url',
|
'config.admin.url',
|
||||||
|
'config.server.url',
|
||||||
'config.environment',
|
'config.environment',
|
||||||
]),
|
]),
|
||||||
};
|
};
|
||||||
@ -61,6 +63,10 @@ module.exports = strapi => {
|
|||||||
|
|
||||||
strapi.router.get('/', serveIndexPage);
|
strapi.router.get('/', serveIndexPage);
|
||||||
strapi.router.get('/index.html', serveIndexPage);
|
strapi.router.get('/index.html', serveIndexPage);
|
||||||
|
strapi.router.get(
|
||||||
|
'/assets/images/(.*)',
|
||||||
|
serveStatic(path.resolve(__dirname, 'assets/images'), { maxage: maxAge, defer: true })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// serve files in public folder unless a sub router renders something else
|
// serve files in public folder unless a sub router renders something else
|
||||||
@ -78,15 +84,7 @@ module.exports = strapi => {
|
|||||||
|
|
||||||
strapi.router.get(
|
strapi.router.get(
|
||||||
`${strapi.config.admin.path}/*`,
|
`${strapi.config.admin.path}/*`,
|
||||||
async (ctx, next) => {
|
serveStatic(buildDir, { maxage: maxAge, defer: false, index: 'index.html' })
|
||||||
ctx.url = path.basename(ctx.url);
|
|
||||||
await next();
|
|
||||||
},
|
|
||||||
koaStatic(buildDir, {
|
|
||||||
index: 'index.html',
|
|
||||||
maxage: maxAge,
|
|
||||||
defer: false,
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
strapi.router.get(`${strapi.config.admin.path}*`, ctx => {
|
strapi.router.get(`${strapi.config.admin.path}*`, ctx => {
|
||||||
|
|||||||
21
packages/strapi/lib/middlewares/public/serve-static.js
Normal file
21
packages/strapi/lib/middlewares/public/serve-static.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const koaStatic = require('koa-static');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// serveStatic is not supposed to be used to serve a folder that have sub-folders
|
||||||
|
const serveStatic = (filesDir, koaStaticOptions = {}) => {
|
||||||
|
const serve = koaStatic(filesDir, koaStaticOptions);
|
||||||
|
|
||||||
|
return async (ctx, next) => {
|
||||||
|
const prev = ctx.path;
|
||||||
|
const newPath = path.basename(ctx.path);
|
||||||
|
ctx.path = newPath;
|
||||||
|
await serve(ctx, async () => {
|
||||||
|
ctx.path = prev;
|
||||||
|
await next();
|
||||||
|
ctx.path = newPath;
|
||||||
|
});
|
||||||
|
ctx.path = prev;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = serveStatic;
|
||||||
Loading…
x
Reference in New Issue
Block a user