Map any resource root to index.html with Spring - spring

In my Spring App I added ResourceHandler to serve static content:
registry.addResourceHandler("/docs/**")
.addResourceLocations("classpath:/docs");
How can I configure auto-forwarding from folder roots to index.html files like so:
/docs/ ==> /docs/index.html
/docs/nested-folder/ ==> /docs/nested-folder/index.html

Related

Rollup Plugin HTML error with multiple index.html files

Firebase hosting can be configured with several index.html file to support localization
public/
index.html // your site's default homepage
404.html // your site's custom 404 page
localized-files/
ALL_ca/
index.html
es_ALL/
index.html
404.html
fr/
index.html
404.html
fr_ca/
index.html
With this structure, #rollup/plugin-html throw
Error: [#web/rollup-plugin-html] Found multiple HTML inputs configured with the same name, or with no name which defaults to index.html. Set a unique name on theinput option.
Renaming index files won't work with Firebase hosting.
How do I go around that ?

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/')

Using public and resources folder as alias in laravel

I split a laravel project into 2 parts, backend and frontend, I created 2 repos on GitHub.
In the frontend repo, there are only 2 folders, public and resources folder.
So, when I pull the changes on frontend, I would like all files to replace in backend folder too.
------ backend folder
---- public folder -> I want to it be an alias
---- resources folder -> I want to it be an alias
----- frontend folder
---- public folder
---- resources folder
When I create an alias of the public and resources folder in frontend, laravel won't work.
If I create a symlink of those frontend folders, laravel works but index.php file doesn't work as it doesn't follow symlinked path
How can I get it working?
To change public folder directory go to root index.php
Under the $app = require_once __DIR__.'/../bootstrap/app.php'; add below line:
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
To change the resource of view folder directory go to config/view.php and change your desire path.
'paths' => [
realpath(base_path('resources/views'))
],

Laravel + Nginx: can we serve app from /something and from a different folder?

On disk
/var/www/mainapp -> some other legacy .php files without any magic url handling
/var/www/laravel - > my laravel app
I must serve
accessing domain.tld -> mainapp
accessing domain.tld/laravel -> my laravel app
The problem is also that Laravel's app are entirelyt served from /var/www/laravel/public/index.php as you of course know
I am not able to set nginx to serve /laravel and all subroutes using laravel app
Something as simple as this should work:
server {
server_name domain.tld;
location / {
root /var/www/mainapp;
# add php/fpm config
}
location /laravel {
root /var/www/laravel;
# add php/fpm config
}
}

Vertx web Routing

I'm new to vertx-web. I'm building web application using ruby vertx-web. I would like to serve static file (index.html) . and My index.html packed inside webroot folder.
My index.html file will load for http://localhost:8088. I need to serve index.html for localhost:8088/demo OR localhost:8088/test OR http://localhost:8088/* (* could be anything and it should serve index.html).
directory structure:
frontend
webroot
index.html
index.css
sever.rb
Any help will be appreciated.
Try this:
router.route("/static/*").handler(&VertxWeb::StaticHandler.create().setWebRoot("webroot").method(:handle))
You could define a default route as last route and set a handler which only sends the index.html file:
router.route().handler(rc -> {
rc.response().sendFile("webroot/index.html");
});
This is the Java version but translating it to Ruby should be easy.
following code works for me.
router.route_with_regex(".*/index.html").handler() { |routingContext| router.route().handler(&VertxWeb::StaticHandler.create().method(:handle))
response = routingContext.response()
response.put_header("content-type", "text/html")
response.set_chunked(true)
response.send_file("webroot/index.html")
}

Resources