Inhalte aufrufen

Profilbild

CORS is not allowed by access-control-allow-origin


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
8 Antworten zu diesem Thema

#1 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 23 October 2014 - 16:12

Hello everyone,

 

I'm trying to install a new store in a new company host and i'm having some mistakes.

 

When i try to simulate the request to the Web API it's returning this error

 

 
It's in portuguese
 
"Pedido entre origens bloqueado: a política de mesma origem proíbe a leitura de recursos remotos em http://localhost:124...a/v1/Customers?$top=3&$inlinecount=allpages. Isto pode ser corrigido movendo-se o recurso para o mesmo domínio ou ativando o CORS."
 
 

Could someone share with me what's the right way to turn arround this problem?

 

thanks 



#2 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 23 October 2014 - 16:39

Is there anyway using this community yet or should i post in another place?

 

Thanks



#3 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 23 October 2014 - 18:31

It's showing 401 error as the autheticated has falled.

 

GET http://localhost:591...a/v1/Customers?$top=3&$inlinecount=allpages 401 (Unauthorized) 

 

But i fill the URL with the right and the credentials.



#4 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 23 October 2014 - 18:32

**401 Unauthorized**: Authentication failed or the user is not authorized (in case of UserHasNoPermission). There is no content returned because no access can be granted to the client.



#5 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3799 Beiträge

Geschrieben: 24 October 2014 - 15:03

Are you working with current code (git 2.x)? It's not working cause of uncomplete refactoring.
I guess to solve it, the only thing to do is to change SmartStore.Web.Framework.WebApi.WebApiGlobal.PluginSystemName into
public static string PluginSystemName { get { return "SmartStore.WebApi"; } }

Marcus Gesing

Smartstore AG


#6 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 24 October 2014 - 15:08

Hi Mrs Gesing,

 

Really thanks for the reply i'm  looking if this is the error. 

 

I feed back soon as i test.

 

Thanks 



#7 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 24 October 2014 - 15:29

It was using 

public static string PluginSystemName { get { return "Api.WebApi"; } }

 

I changed to 

 

public static string PluginSystemName { get { return "SmartStore.WebApi"; } }

 

but the error persist, so i debbug the WebApiAuthenticateAttribute.cs and i checked that the 

 

string headPublicKey = request.Headers[WebApiGlobal.Header.PublicKey];  

 

is null so here is falling in the 

 

if (string.IsNullOrWhiteSpace(headPublicKey))
return HmacResult.UserInvalid;


#8 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 24 October 2014 - 15:39

Could you share with me what version should i download to start a test?



#9 Jefferson

Jefferson

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 30 Beiträge

Geschrieben: 24 October 2014 - 15:55

This is the version that i'm using 

 

 private static readonly List<Version> s_breakingChangesHistory = new List<Version> 
        { 
            // IMPORTANT: Add app versions from low to high
            // NOTE: do not specify build & revision unless you have good reasons for it.
            //       A release with breaking changes should definitely have at least
            //       a greater minor version.
            new Version("1.2"),
            new Version("1.2.1"), // MC: had to be :-(
            new Version("2.0")
        };