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
Related
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.
I want to load a http js file by using require with webpack in the js file instead of using script tag in view page, because some necessary things must be configed before the file loading. The code is like following:
require("http://xxxxx");
but it doesn't work with webpack, how can I make this function?
You can't require external files which resides in different location with webpack. You have to use some library like jQuery / requirejs / script.js to load the external files.
In another SO post here, the second option is to write G.this; in the first "top" file in order to create a namespace.
And then write "use strict" on the top of every other js file.
Is that all the content of such a file? and if so, where the "top" file should be located (server, client, both) and what name? as Meteor loads files based on their paths. Thanks
One of ways to create a global namespace in Meteor (as suggested in the SO answer) is to have a file where a global alias to this is declared, such as:
G = this;
This file should, ideally, be loaded first and on both client and server.
To achieve this, according to the doc:
Files within lib/ directory are loaded first (after loading template files on client).
Meteor will load any file outside client/ or server/ directories on both client and server.
Where no other rules may apply, alphabetical ordering of the paths is used to determine load order of the files.
So, in keeping with these rules I would save the file as app.js (or any similar name that would come first alphabetically). Then I would place this file at the root of lib/ folder so that it gets loaded both on client and server.
So, the path to app.js would be : ./your_meteor_project_root/lib/app.js
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 ?
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