Nginx rewrite static file to versioned file name - nginx

We want to use the same CSS from our JS app in our server side generated pages. The problem is the CSS file names are versioned by grunt-rev like this:
main.css becomes 02668d2c.main.css
We deploy daily so these static file names change regularly and there is no way for the dynamically server side generated pages to have knowledge of the file names.
Question: Is there any way to use NGINX to rewrite requests for main.css to (.*).main.css ?

Related

How to serve a default js file when no file is specified

I'd like to host a library.js file and serve it as default when no library is specified, something similar to index.html.
Just like what stripe does when you download stripe.js from https://js.stripe.com/v3/, without needing to specify the js file name

How to access html file inside iframe in production

I am creating a web app where, this app will generate a .html file in public/ directory. And after that i want to show that generated html file on a page using iframe .
I am using NextJS for this task. I have configured next.config.js for rewrites but getting 404 error. I am using Railway for hosting. Since in Vercel we can not access filesystem here.
Instead of generating html dynamically, if I upload that .html file, then i can access that file using iframe in production.
I think we can not access those files which were not available during build process. (this is my guess , maybe wrong)
How can I solve this problem or should I use another framework ?
Thanks
Since I was accessing .html files (i.e <iframe src="path-to-file"></iframe>) which were not available during build process, that's why i was getting 404 error.
So I did the following thing:
suppose I want to do this <iframe src="/pdf/page01.xhtml"></iframe> where file location is in public/pdf/page01.xhtml.
so this src is sending a GET request to localhost:3000/pdf/page01.xhtml.
To manipulate this request I created a pages/api/pdf/[...slug].js. In this file you can use process.cwd() to access the file inside your public dir. You read file content using fs.readFile and send the response res.status(200).send(data) like this.
By doing this I was getting the desired result.
Suggestions are always welcome.

Insert plain html/css/js pages and add address (route) to them

Say I have html template https://www.free-css.com/free-css-templates/page244/debut How do I insert them into Drupal correctly so that it works exactly as I if've put these files from archive alongside Drupal...? So that if I open "mysite.com/contact.html" I get exactly the contents of contact.html an everything inside (links to css/js files) works.
If I'm understanding, you want to serve a static HTML file from the same domain as a Drupal site, and not bootstrap Drupal in the process, so the static HTML gets served directly. I'd recommend using the Pathed Files module (https://www.drupal.org/project/pathed_files) which lets you upload a static file or paste its contents into a form, and specify a custom URL for it. Alternatively, if you just put an HTML file in the Drupal files directory (e.g. https://your.website.com/sites/default/files/your-html-file.html), your Web server will happily serve it as is, but you have to live with that /sites/default/files/ path in the URL. Truth be told, you could put it right in the Drupal Web root, alongside index.php, and the Web server will serve it without bootstrapping Drupal. But that's very ugly, and you really, really should not do that.

Get Static referenced files with http request in meteor

This can be a silly question but I have had some issues with it. I am trying to implement jwplayer with meteor. Jwplayer will try to get a file based off the url you suggest. So I tried to place a file in localhost:3000/test.mp3. When I tried to hit that url I get just the default site. This would work if I used tomcat. Is there something I can do to get the files relative to meteor directory?
Thanks for your help.
In the /public directory, per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
Meteor hasn't yet implemented server side routing and all directories are ultimately flattened. So for the time being, you can access your file at http://localhost:3000/test.mp3, but that may change in the future.

servlet filter mapping for url-pattern to target specific path in url

I am using jawr. I want to map only js files which has "bundle" folder in its path (/bundle/*.js ) so that other js files which i have it as tag works fine.
currently, if i specify url-mapping as *.js...it will intercept all *.js files. So it starts giving 404 for those files.
I am not sure if this will fix issue, but i think thts only way i can tell jawr script servlet to avoid other js files.
details about my issue
http://java.net/projects/jawr/forums/discussion-forum/topics/655-Included-file-in-jsp-contains-numeric-folder-that-does-not-exist

Resources