/ / How to add sitemap.xml in an angularjs app - javascript, angularjs, xml, gruntjs, sitemap

Como adicionar sitemap.xml em um aplicativo angularjs - javascript, angularjs, xml, gruntjs, sitemap

I have created an angularjs app using gerador-angular-fullstack. Things are working good except one. I"m trying to add sitemap.xml to this app so that it can be indexed by search engines crawlers. Using the approach mentioned Aqui, I created a sitemap.xml in my client/ directory. It is working properly on Development Environment when I start my application using grunt serve but on Production, it"s not working when I"m starting the app using grunhido servir: dist. This is my robots.txt https://crowdvirality.com/robots.txt Whenever I try to access https://www.crowdvirality.com/sitemap-secure.xml ou https://www.crowdvirality.com/sitemap.xml, me redireciona para https://www.crowdvirality.com/error página.

My app.js contains following rule:

  .config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, cfpLoadingBarProvider) {
$urlRouterProvider
.otherwise("/error");
})

This same set up works on local dev environment but fails on prod. Can anyone give me some pointers where I"m doing wrong ?

obrigado

Respostas:

0 para resposta № 1

ok its a common issue i think.

You are basically trying to serve a file instead of a route.

I was doing this the other day with a pdf

You have to create a route with a file extension in your route provider.

Por exemplo ...

.state("sitemap.xml", {url: "/sitemap.xml"})

the . in the state name is vital, this lets angular know you are serving a file and not a route

ATM because you do not have this state, you are falling back on your otherwise state