O
O
Oversec2017-04-07 19:21:45
Node.js
Oversec, 2017-04-07 19:21:45

How to build an application with an admin panel when the client part is a SPA?

The application is written in Nodejs + React + Redux + MongoDb
How can I build the client and admin parts of the application?
at the moment, the structure of the application without the admin panel -server
--models
--routes
--static
-client
--dist
--src
(react app)
are static folders different depending on the part of the application? (admin panel or client side).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hazrat Hajikerimov, 2017-04-07
@Oversec

How would I do it.
1. Using express to write a Restful API
2. Using React+Redux to write an admin panel that communicates with the server via the API
3. Put the admin panel on the https://admin.example.com/
subdomain 4. Develop a website using the same tools as admin panel (react + redux)
5. Give the site when accessing the root application (app.get('/', (req, res) => res.sendFile(path + '/public/index.html'));)
Correct me please if something is wrong explained to the person

A
Andrew, 2017-04-07
@undefined_title

I'm not going for the best solution, but the admin panel can be a separate path example.com/admin, and you need to think carefully about access control, something like assigning groups to users. from the server you need only restapi. you will set the localStorage group of the current user and the token that comes from the server during authorization, now you can find out which user is currently on the site and, depending on this, render different things. you can move the admin panel to a separate router and in the navbar, if the user has an admin group, show a link to the administration page. here I did the USER, ADMIN, MODERATOR roles, there are admins, you can see if something will help
https://github.com/andrey-shostik/video.ck.ua-frontend
https://github.com/andrey-shostik/ video.ck.ua-backend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question