"views" directory missing - javascript

Hey guys am trying to learn sails.js, I have followed some tutorials where the sails.js application has "views" directory (by default) but my setup doesnot have one.
So I created a directory named it "views" inside project directory and then,
I created an index.ejs file with <h1>Hello World</h1> as content.
Configured the route '/': {view: 'static/index'},
Then I tried it in my chrome with localhost:1337 and nothing showed up in the browser, but in the terminal I got a chunk of error out of which I found it saying no such file or directory, open 'c:\project\views\layout.ejs'.
What is it that Iam missing?

It's expected there will be an app-wide layout file (named as what's missing).
Create or copy that file and things should be working again.

Related

Next js serve static js files not working

I have this folder structure for my next.js project
/public
|static
-hello.png
|sample
-test.js
|charting_libray
|bundle
-dist.js
|hello.png
In my local environment
http://localhost:3000/static/hello.webp
http://localhost:3000/hello.webp
http://localhost:3000/static/sample/test.js
All of these works. This means JS, Image anything can be served from nested folders or directly from the public folder.
But when I build the project using next build command and deployed it to the production.
mydomain.com/static/hello.webp
mydomain.com/hello.webp
mydomain.com/static/sample/test.js
I have noticed only the images files can be accessed and the JS file returns 404.
My real-world use case is, inside a component I pass the path to a library like this
libraryPath: "/static/charting_library/"
I can see a net::ERR_ABORTED 404 error in the prod env browser console. Somehow the library works even with this 404 error.
But I need to know the reason for this 404 error and need to fix in the code.
Any help!
Thanks in advance.

Laravel files/folders not showing up in Public directory

I want to integrate TradingView's charting library in my Laravel project.
I have copied the charting_library folder to the Public folder of Laravel.
After that, I have referenced the charting_library.min.js file from Blade files in view and the other resources related to it.
<script type="text/javascript" src="{{ asset('tradingview/charting_library/charting_library.min.js') }}">
All js files loads successfully, but the problem is that this charting_library.min.js calls an HTML file from a subdirectory where it returns a 404 Not Found error.
http://localhost:8000/charting_library/static/fa-tv-chart.37***ee.html 404 (Not Found)
Here is the file/folder structure:
I have checked loaded resources from chrome's dev tools.
Laravel loads these referenced JS files, but it doesn't load any other files which these files have requested and just returns 404.
The charting_library folder exists in the directory, it's just something related to Laravel. I think it can't see the directory's contents.
I have tried to modify the .htaccess file but still no luck.
I even tried to mix charting_library.min.js via Webpack, changing autoload, but still, nothing happens.
I solved this issue by:
Moving the project to wamp's www folder.
Moving charting_library and datafeeds folder to the root of laravel's public. It seems
tradingview's widget constructor uses relative path's for building
whole chart. So when you place the charting_library inside a folder,
it doesn't resolve other assets. These folders should be exactly in
the root.

Overriding layout file Symfony (Aimeos Symfony Bundle)

I have a problem with overriding default template from app/Resources folder to my bundle resource folder. I have installed Aimeos Symfony bundle. And I get this error with opening list route. I moved all view files from app folder to bundle resource. Here is my folder structure project tree:
But i get this error trying to access /list route of Aimeos. I guess it has a wrong path main error:
Why are you "moved all view files from app folder to bundle resource"?
Please, carefully read the installation manual, especially this step - Symfony/Adapt base template.
So there was two ways how you got this error - you missed this installation step or just moved out app/Resources/view/base.html.twig that is important to see /list route.

Grails 3 Application Unable to load *.js file

I have my Grails 3 Application. I have placed my front-end application(which is built using Angular 2.1) in src/main/webapp folder.
While loading the application with URL http://localhost:8080/ I'm redirecting it to Index.html page.
But the Index.html page is not loading
URL:-http://localhost:8080/static/app-name/index.html
And I'm getting below errors in console.
GET http://localhost:8080/inline.js
index.html:14
GET http://localhost:8080/main.78fb007fcde8966a4e95.bundle.js
index.html:14
GET http://localhost:8080/styles.d63e17da56bb3a1ca523.bundle.js
index.html:14
GET http://localhost:8080/main.78fb007fcde8966a4e95.bundle.js 404 ()
Change it so resources don't get served from the /static url:
application.yml:
grails:
resources:
pattern: /**
Finally, I got the solution.
1.) Copied the contents of dist instead of dist folder itslef into src/main/webapp
2.)Made the changes in application.yml as suggested by #James Kleeh.
3.)Re-Route controller uri to index.html.
And here it goes.
PS: I was actually facing path issue which got resolved following above steps

Serving ember app from IIS resulting in UnrecognizedURLError

I am trying to serve an ember app from IIS.
I created a new app using ember new my-app and then ran ember build --environment production. This generated the files in the dist directory as expected.
On the IIS side, I added a new website on the server and mapped the dist folder from the last step.
Now, when I navigate to localhost/index.html I get a blank page.
I checked the source of the page and the js files are being served correctly as expected. This would mean that it's the templates that are not being retrieved correctly. In the chrome inspector console there is an exception which says Uncaught: UnrecognizedURLError: /index.html. The ember inspector says 'Ember application not detected!'.
I've tried the solutions mentioned here, but none has worked for me.
Has anyone else experienced this problem/know how to fix this?
Ember Router uses location: history by default. This means, it assumes that /index.html is your route. But obviously it's not defined so the router throws UnrecognizedURLError.
There are several solutions for your problem:
Set locationType: 'hash' in config/environment.js of your ember application. This will force Ember router to use # in url for routing and in your case this would be like localhost/index.html#your/route.
Configure your IIS instance to handle index.html as a default document. To do this, open your server config and make sure it has the key:
Change ember build config to produce index.aspx instead of index.html. You can read about it here.

Categories

Resources