I've just finished creating my custom error messages in my Nuxt.js application in layouts/error.vue. For the moment I've made it pretty simple as it's just a brochure site for the time being, so I am just handling the errors as shown below as for now I only care about users hitting a page that doesn't exist.
<template v-if="error.statusCode === 404">
<h1>Sorry!</h1>
<p>We can't find the page you are looking for.</p>
</template>
<template v-else>
// Some other message
</template>
When running my application locally, and trying to navigate to a route that doesn't exist, this works perfectly and my error message is displayed.
However, my hosted application does not behave how I want it to. I'm hosting the application on IBM Cloud as a Cloud Foundry application. The application uses the static buildpack, and my manifest.yml file looks like so:
---
applications:
- name: name
path: ./dist
buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git
random-route: true
But if I try and navigate to an incorrect route that way, I am displayed the generic nginx 404 error:
I understand that there are 2 ways you can tell Cloud Foundry that the application requires a static buildpack - Declaring the buildpack in the manifest.yml OR adding a file named Staticfile in the dist directory after running npm run generate. Within this file, you can add some configurations, one of which being status codes which:
Allows to define custom pages for HTTP STATUS codes instead of the default NGINX pages.
status_codes:
404: /404.html
500: /500.html
However, my error handling is done in a layout, not a page. And my generated project folder does not contain a page called error anywhere, so I don't know how to use this method to use my error handling.
If anybody could give me some pointers on how to correctly do it, it would be greatly appreciated!
Related
I am able to add multiple ids in the id array and it loads well and properly adds the script on local
However, when the code makes it to production, it throws invalid errors because the IDs are getting concatenated(probably due to minified files, not sure). How can I fix this?
Pictures of local and deployed version are attached
Google tag manager on prodution
Google tag manager on my local machine
Here's is my config code using vue-gtm
Vue.use(VueGtm, {
id: ['GTM-M4X2575', 'GTM-T98TL4V'],
enabled: true,
debug: true
});
Am I missing anything?
Using stencil 3.0.3, node 12.21 cornerstone theme was working and suddenly stopped with a weird server error:
Debug: internal, implementation, error
Error: The BigCommerce server responded with a 500 error
at Object.internals.getResponse (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/server/plugins/renderer/renderer.module.js:128:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async internals.implementation (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/server/plugins/renderer/renderer.module.js:39:20)
at async module.exports.internals.Manager.execute (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/node_modules/#hapi/hapi/lib/toolkit.js:45:28)
at async Object.internals.handler (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/node_modules/#hapi/hapi/lib/handler.js:46:20)
at async exports.execute (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/node_modules/#hapi/hapi/lib/handler.js:31:20)
at async Request._lifecycle (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/node_modules/#hapi/hapi/lib/request.js:312:32)
at async Request._execute (/usr/local/lib/node_modules/#bigcommerce/stencil-cli/node_modules/#hapi/hapi/lib/request.js:221:9)
I have tried to re-install big commerce stencil, clean build and still get the same error.... at this point I have no idea what could be causing this issue.
Importantly, there was no code changes in between the day where everything was working and the day where it stopped.
Are you using CloudFlare for a CDN? I've ran into this issue and have had to edit my hosts file
I add the following 3 lines.
The first one is for the Store Domain, i.e. if you have MyShoeStore.com
The second 2 contain the auto-generated store-hash for a BigCommerce store that should be visible in your URL bar if you are on the BigCommerce control panel (Logged into the admin view - that's the easiest way to get it, there are some others)
35.186.223.98 mystoredomain.com
35.186.223.98 store-abcdefg[store-hash].mybigcommerce.com
35.186.223.98 www.store-abcdefg[store-hash].mybigcommerce.com
For some reason, Stencil-CLI gets thrown for a loop when trying to connect to a BigCommerce store that is running behind CloudFlare CDN. This has caused 500 errors in the Stencil-CLI, and a failure to render, during local development, but the store is able to be uploaded and hosted in production without a problem.
I'm not sure if this is the actual issue that you had which caused your 500 error, (It can be due to an error in the syntax of one of the HandleBars templates, but usually Stencil-CLI will output an informative error for that reason.)
The other situation I have seen this in is if you are trying to run Cornerstone on a very old BigCommerce store which is still running their old template framework (Blueprint) - in that situation, certain pages will 500, but others will work.
This may be helpful for others who are running into this.
I installed a proxy tool to capture traffic between stencil and BigCommerce in order to perhaps find more details on this error.
Unfortunately, as soon as I did that, the site worked again...
I got the following error in my Vue SPA:
Refused to execute inline script because it violates the following Content Security
Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword,
a hash ('sha256-KpHv3zgivMSB4dPnfYfqMt2lBibsYvM36EdoBBAsfbM='), or a nonce ('nonce-...')
is required to enable inline execution. Note also that 'script-src' was not explicitly set,
so 'default-src' is used as a fallback.
This error caused by Browsersync:
First, this error occurs only if browser has been reloaded by browsersync in non-root route. For example, this error occurs in http://localhost:3001/sign-in, but never occurs in http://localhost:3001.
Next, this error occurs only in SPA, but never occurs in normal website (multiple pages, no manipulations with HTML5 history). So, I suppose, vue-router is involved.
My hypothesis about the cause is the BrowserSync was wrong. The cause is my past incomprehension how front-end routing works. Let's see what's going on in history mode of vue-router:
Once building complete, new tab in browser with route "/" will open.
Vue-router generates the routes including /sign-in.
When we go to non-root page, e. g. to http://localhost:3000/sign-in
If we make corrections in code, the project will be re-built.
Browser-sync will reload the page http://localhost:3000/sign-in. But Browser Sync does not know what he must to return for http://localhost:3000/sign-in route! It's the static server, it knows only http://localhost:3000/ and can return files relative to directory respective to http://localhost:3000. There is no file sign-in, so it error will occur.
This routes like sign-in has been created by vue-router in http://localhost:3000/ page during routing initialization, but this data will be lost on next browser reloading.
Solutions
I am sure that more than 10 approaches exists (for various project building tools), but I am satisfied with hash mode on local development mode. To enable the history mode on production and/or testing mode, the appropriate server setup required. Most likely it's possible to setup the Browser Sync to redirect like http://localhost:3000/sign_in => http://localhost:3000/.
I don't use the tools like create-vue-app, but I suppose the Webpack pre-setted somehow to avoid above issue (Webpack hot module replacement?).
I am new to use ArcGis Api for javascript, I am using JS Api 3.20.
I have been trying for 3 days but it does not work.
I have taken code from the following link
Geometry Engine - Geodesic buffers | ArcGIS API for JavaScript 3.20
I paste this in My Html file create in VS website for .Net , and setup a local server for my page using IIS server
I also downloaded proxy from GitHub resource-proxy/DotNet at master · Esri/resource-proxy · GitHub
setup it in same application in IIS
Downloaded excel file added in my application from https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv
but still I am getting the following error in console using developer mode when set Proxy URL to this
config.defaults.io.proxyUrl = "/192.168.8.188/Proxy/proxy.ashx";
GET http://192.168.8.188:1555/192.168.8.188/Proxy/proxy.ashx?http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv 404 (Not Found)
and when I set proxy url to this
config.defaults.io.proxyUrl = "/Proxy/";
then the following error occurs in console
GET http://192.168.8.188:1555/Proxy/?http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv 403 (Forbidden)
Could you please help me out. I would be thankful in advance.
I Resolved My Issue thanks.
Basically I didn't enable IIS 4.5 web features so I read readme file of proxy which resolved my issue.
Here is what I read from ReadMe file located in DotNet folder of Proxy
Troubleshooting: If you get an error message 404.3, it's possible that ASP.NET have not been set up. On Windows 8, go to "Turn Windows features on or off" -> "Internet Information Services" -> "World Wide Web Services" -> "Application Development Features" -> "ASP.NET 4.5".
First off, try setting the proxyUrl value to this:
config.defaults.io.proxyUrl = "/proxy/proxy.ashx";
That may resolve the issue.
EDIT (based on clarification that IIS is in fact running on port 1555):
You might want to confirm that you can access the proxy at all, by entering the proxy url directly in your browser (with no arguments), eg:
http://192.168.8.188:1555/Proxy/proxy.ashx
If this resolves correctly, you should get an error response in JSON format like this:
{error: {code: 400,message:"This proxy does not support empty
parameters."}}
That at least would confirm that the proxy is accessible and functioning properly on your system.
After having finished and tested an Angular2 application on my local machine, I decided to move it to an AWS cloud server with Apache.
I cloned the sw from git but, as soon as I launched the app, I got an error on the browser console stating:
EXCEPTION: Template parse errors:
Only void and foreign elements can be self closed "head" ("[ERROR ->]<head/>
After some research I found that all of my external html templates are magically enriched with a starting <head/> tag which I do not see trace of in my code.
To fix this I had to turn off mod-pagespeed .Since I am not familiar with Apache configuration I do not know which side effects this may have and whether there is any better solution. Any help would be very much appreciated.
I believe mod-pagespeed has an option where it automatically adds a head tag to an html document if it cannot find it in the document (before the body). To turn off this feature add this to your pagespeed apache configuration (ie. in the .htaccess):
To prevent javascript alterations also forbid a couple more filters
ModPagespeedForbidFilters add_head,rewrite_javascript,rewrite_javascript_inline,combine_javascript,inline_javascript
This way you can still enjoy the rest of the mod-pagespeed features :)