mirror of
https://github.com/strapi/strapi.git
synced 2025-11-24 14:11:05 +00:00
Fix plugin generator
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
576a603ed6
commit
349d384a7d
6
examples/kitchensink/config/admin.js
Normal file
6
examples/kitchensink/config/admin.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = ({ env }) => ({
|
||||||
|
// autoOpen: false,
|
||||||
|
auth: {
|
||||||
|
secret: env('ADMIN_JWT_SECRET', 'example-token'),
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* This component is the skeleton around the actual pages, and should only
|
|
||||||
* contain code that should be seen on all pages. (e.g. navigation bar)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import { Switch, Route } from 'react-router-dom';
|
|
||||||
import { NotFound } from '@strapi/helper-plugin';
|
|
||||||
import pluginId from '../../pluginId';
|
|
||||||
import HomePage from '../HomePage';
|
|
||||||
|
|
||||||
const App = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Switch>
|
|
||||||
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
|
|
||||||
<Route component={NotFound} />
|
|
||||||
</Switch>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* HomePage
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { memo } from 'react';
|
|
||||||
// import PropTypes from 'prop-types';
|
|
||||||
import pluginId from '../../pluginId';
|
|
||||||
|
|
||||||
const HomePage = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>{pluginId}'s HomePage</h1>
|
|
||||||
<p>Happy coding</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(HomePage);
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Initializer
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { useEffect, useRef } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import pluginId from '../../pluginId';
|
|
||||||
|
|
||||||
const Initializer = ({ setPlugin }) => {
|
|
||||||
const ref = useRef();
|
|
||||||
ref.current = setPlugin;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
ref.current(pluginId);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Initializer.propTypes = {
|
|
||||||
setPlugin: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Initializer;
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* axios with a custom config.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
import { auth } from '@strapi/helper-plugin';
|
||||||
|
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.interceptors.request.use(
|
||||||
|
async config => {
|
||||||
|
config.headers = {
|
||||||
|
Authorization: `Bearer ${auth.getToken()}`,
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
};
|
||||||
|
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
instance.interceptors.response.use(
|
||||||
|
response => response,
|
||||||
|
error => {
|
||||||
|
// whatever you want to do with the error
|
||||||
|
if (error.response?.status === 401) {
|
||||||
|
auth.clearAppStorage();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default instance;
|
||||||
Loading…
x
Reference in New Issue
Block a user