How to set up an url prefix to access to the admin panel and the strapi server - strapi

Here you can see the server.js file configuration. Apparently all is working fine but if I put in the browser the url of the admin panel: http://localhost:1337/aplicaciones/strapi_accuee/admin it doesn't work. This is the image of the error:
Can anybody help me to configure properly this url prefix (/aplicaciones/strapi_accuee) in strapi?

config/server.js url is a baseUrl of your strapi project.
config/admin.js url is one that is appended to baseUrl to access admin panel.
so to setup it up properly, i would recomend adding .env file to the root of your project and set it up as so:
URL=http://localhost:1337
PUBLIC_ADMIN_URL=/myCustomAdminRoute
in config/server.js
module.exports = ({env}) => {
...
url: env("URL", "http://localhost:1337"),
...
in config/admin.js
module.exports = ({env}) => {
...
url: env("PUBLIC_ADMIN_URL", "/admin"),
...
yarn build
yarn develop
this would give you admin panel at:
http://localhost:1337/myCustomAdminRoute/
Api route:
http://localhost:1337/api/
For http://localhost:1337/aplicaciones/strapi_accuee
i suspect you want to move api under /aplicaciones/strapi_accuee/api and uploads under aplicaciones/strapi_accuee/uploads
in .env specify following:
URL=http://localhost:1337/aplicaciones/strapi_accuee
PUBLIC_ADMIN_URL=/admin
and do:
yarn build
yarn develop

Related

Laravel vue 3 remove /build/ from url

Let me start of with the fact that im new to laravel and english is not my main language so dont mind my grammer. I have a project that has a laravel api with a vue front-end. The Laravel web routing redirects everything to a single blade file that contains the vue app. this way i can use the vue routing. This is has all been working fine for a while now but now im trying to build for production and ive run into the following issue.
after using npm run build to build for production laravel puts /build/ to every route im using through vue. This is very logical given that it uses the build folder in the public directory like it should. But its ofcourse verry ugly for the users. Is there a way to remove the /build/ from the url? (appart from redirecting /build/ to / in the .htacces file on the server)
You can set the environment variables in .env file for javascript using VITE_ prefix as below:
Please add the new environment variable in .env file as below:
VITE_BASE_URL="/"
Made the router related changes in your Vue file as below:
const router = createRouter({
history: createWebHistory(import.meta.env.VITE_BASE_URL || '/'),
routes: [
.....
],
})
Problem from import.meta.env.BASE_URL in vitejs, in build mode this import.meta.env.BASE_URL result "/build/" and development mode result, is "/"
I don't know where to change this, but I fix this problem with
const router = createRouter({
history: createWebHistory("/"),
routes: [
{
......
}
]
})
and fix it

Laravel App Not Loading CSS From Public Installation Not In public_html

I've installed a pre-made Laravel app and followed the documentation to extract it to the public root except in the documentation they are installing it into public_html, but I have it in a subdomain in a folder named "test" which is on the same level as public_html.
All the CSS and JS should be loading from the public subdirectory, but they try to look for it in the main root folder.
For example, this file returns a 404 error:
https://test.mydomain.com/css/style.css
The file is actually at this location:
https://test.mydomain.com/public/css/style.css
The absolute path of the file is:
/home/mydomain/test/public/css/style.css
Instead of:
/home/mydomain/public_html/public/css/style.css
What environment or config file isn't set correctly and how do I set it to use the correct directory?
UPDATE
Changing the ASSET_URL to "public" fixed the first issue, but now the same thing is happening with the admin.
The app tries to load the dashboard with this URL:
https://test.mydomain.com/admin/dashboard
The page loads all the assets normally when I remove the word "admin" from the URL:
https://test.mydomain.com/dashboard
But this doesn't work for all the pages.
You can try to put public directory path in below given conflagration file.
Config File Path : config/app.php (asset_url)
'asset_url' => env('ASSET_URL', 'https://test.mydomain.com/public/')

How to custom strapi Admin UI v4?

I have tried to change the HomeHeader of the Admin page, but it has no changes.
I copy admin folder in node_modules/#strapi/admin/admin to my-project/admin and then I modified HomeHeader.js file as the image below:
I started strapi with the command yarn strapi develop --watch-admin, and nothing happened
Please help me to custom this! Thanks
Strapi Version: 4.0.4
Operating System: MacOs
Database: postgres Node
Version: v14.18.1
NPM Version: 6.14.15
Yarn Version: 1.22.10
In Strapi-v3 you can customize the admin panel UI, but in v4 you can't.
there is an opened issue in GitHub about this problem.
I also encountered this requirement of a client.
To replace or customize Strapi admin dashboard home, you can overwrite the file using webpack.
First make sure to install webpack-dev-server in devDependencies.
Create a component file in src/admin/components/Home.tsx with basic React component code.
on the file src/admin/webpack.config.js write this code to replace the original Home page.
module.exports = (config, webpack) => {
...
/**
* Overwrite the dashboard home Component
*/
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/.cache\/admin\/src\/pages\/HomePage\/index\.js/,
path.resolve(__dirname, "components/Home.tsx")
)
);
....
// Important: return the modified config
return config;
};
then re-build you app.

Hosting Laravel in Cpanel doesn't run application

I have problem when I'm trying to access home routes on website, but it seems that it doesn't pass form index.php
dir of require and $app are work because when I dd(1); after it, it show result in website
require __DIR__.'/system/vendor/autoload.php';
$app = require_once __DIR__.'/system/bootstrap/app.php';
dd(1);
but , the problem when handling the incoming request in kernel , which means run application in same file (index.php)
the error after sending response
The GET method is not supported for this route. Supported methods: HEAD.
You should not mess with those files. Seems that you havent defined the document root from the application.
Make sure that the document root is set to the folder public/ inside the project folder.
Found solution ,
I should use base URL as "/" not "/FolderProject"
pathInfo: "/"
requestUri: "/"
baseUrl: ""
basePath: ""

Using Vuepress within a Laravel project

I'm actually running a Laravel website in which I would like to run a Vuepress documentation section.
Installing Vuepress is quite straightforward thanks to the instructions and so is the development server.
However, when it comes to integrating it as a static site, I'm kind of lost with the interactions with the Laravel.
All my documentation is located in a docs folder located on the root of the my Laravel App.
I managed to set up Vuepress' config.js to build the static site into another folder.
base: '/docs/',
dest:'./public/docs',
Doing the above, exposes the documentation is entirely exposed to the web (in the public folder).
However, what I'm looking for is to integrate it more precisely in Laravel (with the middleware and routes I created).
Method 1
1. Install vuepress in /docs in your laravel directory
2. Configure vuepress with the correct base and dest
/docs/.vuepress/config.js
module.exports = {
dest: 'public/docs',
base: 'docs/',
};
3. Enable laravel views to include files from the /public directory
/app/config/view.php
...
'paths' => [
resource_path('views'),
base_path('public'), // now blade's #include will also look in /public
],
...
4. Create a laravel route for vuepress that allows .html extension
/routes/web.php
use View;
Route::get('/docs', function() {
View::addExtension('html', 'php'); // allows .html
return view('docs.index'); // loads /public/docs/index.html
});
Method 2
Or for more control for assets through Laravel, you can try this tutorial here: https://serversideup.net/vuepress-within-a-laravel-application/
# install as a local dependency
yarn add -D vuepress # OR npm install -D vuepress
# create a docs directory
mkdir docs
# create a markdown file
echo '# Hello VuePress' > docs/README.md
package.json
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}
/docs/.vuepress/config.js
module.exports = {
dest: 'public/docs',
base: '/docs/',
};
npm run docs:build
/routes/web.php
Route::get('/docs', function() {
return File::get(public_path() . '/docs/index.html');
});

Resources