Closed num3r06 closed 5 years ago
The asset()
helper method uses your APP_URL
to determine what path to use. You likely need to update APP_URL
in your .env file to include "ater/public". This is almost 100% not specific to Nova
in nova's layout.blade.php it's not used asset() helper but mix() helper:
<link rel="stylesheet" href="{{ mix('app.css', 'nova-assets') }}">
i change APP_URL in the .env file but nothing change this is my .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=http://localhost/ater/public/
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
DB_DATABASE=ater
DB_USERNAME=root
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
``
the ater folder it's a subfolder of root's apache folder
Having the same issue. The problem is, the mix-manifest does not take into account the app URL, or the possibility that the application is not in the root path. IE www.site.com/laravel-app/
.
Any chance for this. I don't want to use Valet or Doker for development and the only solution for locally development on windows it's a wamp server with many root's directory subfolder (i use bitnami wampstack)
Why don't you use php artisan serve
for local development?
Yes i can but i want to know if it's possible using nova in a subfolder
Worth noting that this is not just a local development issue. It’s extremely likely that laravel is used in a production environment that warrants deploying in a sub folder
mix()
in your nova::layout view with your adjusted paths/nova-api
with your adjusted paths... That might work.
Well yeah, until you need to update Nova to the latest release. We shouldn't need to manually make this change.
No you shouldn't have to. Perhaps this is a unpopular opinion, but I don't believe you should ever need to install laravel in a subfolder, production or otherwise. Vhosts are free and easy to set up. Subdomains are free once you own the domain they fall under. Just take the time to set it up "right" and you won't haa any of these problems
Yeah, unfortunately that's not always true. I work for a university where 3rd-level domains are a premium, and are rarely given out except under very specific circumstances. Nova shouldn't make assumptions about the deployment strategy for an application, and for the record, installing a laravel app in a subfolder is not "the wrong way", considering the base framework supports this just fine. It should be flexible enough to support whatever APP_URL is set to. This is not a large ask.
couldn't this easily be fixed by replacing
<link rel="stylesheet" href="{{ mix('app.css', 'nova-assets') }}">
with
<link rel="stylesheet" href="{{ asset(mix('app.css', 'nova-assets')) }}">
?
That only gets the assets loading. All of the API endpoints are hard-coded to /nova-api
throughout the application.
Why not create a proper vHost Configuration or at least use RewriteBase /yoursubfolder in your .htaccess :-)
My subfolder's name is ater. Can you help me to write the .htaccess file correctly thanks a lot
Try adding alias for both nova and nova-api in httpd.conf, then restart apache.
Alias "/nova" "/var/www/html/ater/public/nova"
Alias "/nova-api" "/var/www/html/ater/public/nova-api"
Where /var/www/html/ater/public/nova
is the full path to nova.
I try but not works
@num3r06 it worked for me, try restarting the apache server.
Adding also this works
Alias /vendor/nova /var/www/html/ater/public/vendor/nova
thx
Sorry, All works fine but nova-api path seems to be hardcoded and not configurable. There's a chance to overwrite this path?
Nova needs to honor the APP_URL .env-setting, all other comments about cheap subdomains, etc are totally senseless. Oh yeah, and the "solution" by adding an alias to the vhosts conf is useless, too if one needs more than a single Nova installation on one domain/subdomain.
I have same issue and i have tried adding asset() helper to every mix() call in nova blade resources, Now i'm getting 404 !!
For anyone who has issue installing it in a subfolder, this is how I got it working for me: https://gist.github.com/chinleung/2e9f6a9496ded8cd6fadc829b0030229
is there any good solution for this issue ?
You may use illuminatech/override-build to apply @chinleung's patch.
Assuming your domain is 'http://test.devel' and subfolder named 'subfolder, the configuration for it will be following:
<?php
// file 'config/override-build.php'
return [
'packages' => [
'nova' => [
'srcPath' => base_path('vendor/laravel/nova'),
'buildPath' => base_path('vendor/laravel/nova'),
'patches' => [
'resources/js/util/axios.js' => [
'__class' => Illuminatech\OverrideBuild\Patches\Replace::class,
'replaces' => [
'axios.create()' => "axios.create({baseURL: 'http://test.devel/subfolder'})"
],
],
'resources/views/layout.blade.php' => [
'__class' => Illuminatech\OverrideBuild\Patches\Replace::class,
'replaces' => [
'"/nova-api/' => '"/subfolder/nova-api/',
"mix('app.css', 'vendor/nova')" => "asset(mix('app.css', 'vendor/nova'))",
"mix('manifest.js', 'vendor/nova')" => "asset(mix('manifest.js', 'vendor/nova'))",
"mix('vendor.js', 'vendor/nova')" => "asset(mix('vendor.js', 'vendor/nova'))",
"mix('app.js', 'vendor/nova')" => "asset(mix('app.js', 'vendor/nova'))",
'@json(Nova::jsonVariables(request()));' => "@json(Nova::jsonVariables(request()));\nwindow.config.base = '/subfolder' + window.config.base;"
],
],
],
'buildCommand' => [
'mv webpack.mix.js.dist webpack.mix.js',
'yarn install',
'yarn run '.((env('APP_ENV') === 'production') ? 'prod' : 'dev'),
],
],
],
]
Rebuild command:
php artisan override-build nova
It will still leave the login form CSS messed up, but you can figure it up.
In order to make it better without messing up 'vendor' directory, you may use separated directory for the JS build exporting results to 'public/vendor/nova'. The config for this will be:
<?php
// file 'config/override-build.php'
return [
'packages' => [
'nova' => [
'srcPath' => base_path('vendor/laravel/nova'),
'buildPath' => storage_path('build-override/nova'),
'srcFiles' => [
'resources',
'.babelrc',
'mix-manifest.json',
'package.json',
'tailwind.js',
'webpack.mix.js.dist',
'yarn.lock',
],
'patches' => [
'resources/js/util/axios.js' => [
'__class' => Illuminatech\OverrideBuild\Patches\Replace::class,
'replaces' => [
'axios.create()' => "axios.create({baseURL: 'http://test.devel/subfolder'})"
],
],
'webpack.mix.js.dist' => [
'__class' => Illuminatech\OverrideBuild\Patches\Replace::class,
'replaces' => [
".copy('public', '../nova-app/public/vendor/nova')" => ".copy('public', '../../public/vendor/nova')",
],
],
'resources/views/layout.blade.php' => [
'__class' => Illuminatech\OverrideBuild\Patches\Replace::class,
'replaces' => [
'"/nova-api/' => '"/subfolder/nova-api/',
"mix('app.css', 'vendor/nova')" => "asset(mix('app.css', 'vendor/nova'))",
"mix('manifest.js', 'vendor/nova')" => "asset(mix('manifest.js', 'vendor/nova'))",
"mix('vendor.js', 'vendor/nova')" => "asset(mix('vendor.js', 'vendor/nova'))",
"mix('app.js', 'vendor/nova')" => "asset(mix('app.js', 'vendor/nova'))",
'@json(Nova::jsonVariables(request()));' => "@json(Nova::jsonVariables(request()));\nwindow.config.base = '/subfolder' + window.config.base;"
],
],
],
'buildCommand' => [
'yarn install',
'yarn run '.((env('APP_ENV') === 'production') ? 'prod' : 'dev'),
],
],
],
]
Rebuild command:
php artisan override-build nova
Once build is complete you should manually move layout file from 'storage/build-override/nova/resources/views/layout.blade.php' to 'resources/views/vendor/nova/layout.blade.php' using native Nova view override principle.
I submitted a simple patch long time ago (you need to activate access to the repository within the nova buying application settings) but the developers decided to not include it. I attached the patch to this comment. I am applying this patch for a long time and it's working for every new version without any problems or conflicts (you need to rebuild the assets after patching). My patch has a few more lines changed compared to the changes by @klimov-paul because i tries to make the most simple fundamental changes so nova plugins work without any problems too.
I appreciate that this is not going to be to everybody's liking, but I'm closing this issue. Reasons being:
@jbrooksuk, I afford to remind you, that we are not talking about free open-source project here. Everyone here have payed money for the Laravel Nova access.
If this is your resolve, you should make a refund to every participant of this conversation, as, in fact, you have sold them product, which is broken, and you refuse to fix it up.
It's not broken, you just don't like the outcome, which is based on already-established best practices for Laravel. Locking.
Hi In reference a #181 In windows my development environment it's a bitnami wampstack with apache. My laravel app it's in a root subfolder's http://localhost/ater/public and work fine. When I've installed nova the admin panel search the asset on root folder's and obviusly not found. with php artisan serve works There's a way for using nova in this mode? This is a fresh installation of laravel with nova 1.0.12 Thx