首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WSO2 APIM4.0.0的第一个API,创建似乎很好,但是HTTP404尝试调用API时

使用WSO2 APIM4.0.0的第一个API,创建似乎很好,但是HTTP404尝试调用API时
EN

Stack Overflow用户
提问于 2021-11-12 16:04:55
回答 1查看 563关注 0票数 0

我在虚拟机上使用简单的Node https://apim.docs.wso2.com/en/latest/install-and-setup/setup/single-node/configuring-a-single-node/新安装了一个https://apim.docs.wso2.com/en/latest/install-and-setup/setup/single-node/configuring-a-single-node/ API 4.0.0实例。

我可以在WSO2发布服务器中创建我的API (使用内部现有的API或pizzashack示例)。但是,当我试图调用API时,使用“尝试退出”菜单时,我有一个简单的'TypeError: NetworkError‘尝试获取资源。

在firefox浏览器控制台中,我在对API管理器的选项调用中出现了一个“CORS缺失允许原产地”错误。对于这个问题,我已经应用了https://apim.docs.wso2.com/en/latest/design/advanced-topics/enabling-cors-for-apis/,但没有成功。

这是我所做的定制的deployment.toml文件。

代码语言:javascript
复制
[server]
hostname = "apim-p.<redacted dns>.com"
#offset=0
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"

[super_admin]
username = "<redacted username>"
password = "<redacted password>"
create_admin_account = true

[user_store]
type = "database_unique_id"

[database.apim_db]
type = "postgre"
url = "jdbc:postgresql://<redacted IP>:5432/wso2_apim"
username = "wso2"
password = "<redacted password>"
pool_options.maxActive = 10

[database.shared_db]
type = "postgre"
url = "jdbc:postgresql://<redacted IP>:5432/wso2_shared"
username = "wso2"
password = "<redacted password>"
pool_options.maxActive = 50

[keystore.tls]
file_name =  "apim.<redacted dns>.com.jks"
type =  "JKS"
password =  "<redacted password>"
alias =  "apim-p.<redacted dns>"
key_password =  "<redacted password>"

#[keystore.primary]
#file_name =  "wso2carbon.jks"
#type =  "JKS"
#password =  "wso2carbon"
#alias =  "wso2carbon"
#key_password =  "wso2carbon"

#[keystore.internal]
#file_name =  "wso2carbon.jks"
#type =  "JKS"
#password =  "wso2carbon"
#alias =  "wso2carbon"
#key_password =  "wso2carbon"

[[apim.gateway.environment]]
name = "Production"
type = "production"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"
ws_endpoint = "ws://apim-p.<redacted dns>.com:9099"
wss_endpoint = "wss://apim-p.<redacted dns>.com:8099"
http_endpoint = "http://apim-p.<redacted dns>.com:${http.nio.port}"
https_endpoint = "https://apim-p.<redacted dns>.com:${https.nio.port}"
websub_event_receiver_http_endpoint = "http://apim-p.<redacted dns>.com:9021"
websub_event_receiver_https_endpoint = "https://apim-p.<redacted dns>.com:8021"

[apim.sync_runtime_artifacts.gateway]
gateway_labels =["Default"]

#[apim.cache.gateway_token]
#enable = true
#expiry_time = "900s"

#[apim.cache.resource]
#enable = true
#expiry_time = "900s"

#[apim.cache.km_token]
#enable = false
#expiry_time = "15m"

#[apim.cache.recent_apis]
#enable = false

#[apim.cache.scopes]
#enable = true

#[apim.cache.publisher_roles]
#enable = true

#[apim.cache.jwt_claim]
#enable = true
#expiry_time = "15m"

#[apim.cache.tags]
#expiry_time = "2m"

[apim.analytics]
enable = false
config_endpoint = "https://apim-p.<redacted dns>.com:8080/auth/v1"
auth_token = ""

#[apim.key_manager]
#service_url = "https://localhost:${mgt.transport.https.port}/services/"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#pool.init_idle_capacity = 50
#pool.max_idle = 100
#key_validation_handler_type = "default"
#key_validation_handler_type = "custom"
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler"

#[apim.idp]
#server_url = "https://localhost:${mgt.transport.https.port}"
#authorize_endpoint = "https://localhost:${mgt.transport.https.port}/oauth2/authorize"
#oidc_logout_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/logout"
#oidc_check_session_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/checksession"

#[apim.jwt]
#enable = true
#encoding = "base64" # base64,base64url
#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
#claim_dialect = "http://wso2.org/claims"
#convert_dialect = false
#header = "X-JWT-Assertion"
#signing_algorithm = "SHA256withRSA"
#enable_user_claims = true
#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.ExtendedDefaultClaimsRetriever"

#[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
#revoke_endpoint = "https://localhost:${https.nio.port}/revoke"
#enable_token_encryption = false
#enable_token_hashing = false

[apim.devportal]
url = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/devportal"
#enable_application_sharing = false
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl"
#display_multiple_versions = false
#display_deprecated_apis = false
enable_comments = false
enable_ratings = false
enable_forum = false
enable_anonymous_mode=false
enable_cross_tenant_subscriptions = false
#default_reserved_username = "apim_reserved_user"

[apim.cors]
allow_origins = "*"
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey","Internal-Key"]
allow_credentials = false

#[apim.throttling]
#enable_data_publishing = true
#enable_policy_deploy = true
#enable_blacklist_condition = true
#enable_persistence = true
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"]

#[apim.throttling.blacklist_condition]
#start_delay = "5m"
#period = "1h"

#[apim.throttling.jms]
#start_delay = "5m"

#[apim.throttling.event_sync]
#hostName = "0.0.0.0"
#port = 11224

#[apim.throttling.event_management]
#hostName = "0.0.0.0"
#port = 10005

#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "loadbalance"

#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "failover"

#[apim.workflow]
#enable = false
#service_url = "https://localhost:9445/bpmn"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/admin/v0.17/workflows/update-workflow-status"
#token_endpoint = "https://localhost:${https.nio.port}/token"
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register"
#client_registration_username = "$ref{super_admin.username}"
#client_registration_password = "$ref{super_admin.password}"

#data bridge config
#[transport.receiver]
#type = "binary"
#worker_threads = 10
#session_timeout = "30m"
#keystore.file_name = "$ref{keystore.tls.file_name}"
#keystore.password = "$ref{keystore.tls.password}"
#tcp_port = 9611
#ssl_port = 9711
#ssl_receiver_thread_pool_size = 100
#tcp_receiver_thread_pool_size = 100
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"]
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"]

[apim.notification]
from_address = "apim-p@<redacted dns>.com"
#username = "APIM"
#password = "APIM+123"
hostname = "smtp.<redacted dns>.com"
port = 25
#enable_start_tls = false
enable_authentication = false
signature = "API Manager PROD"

[output_adapter.email]
from_address = "apim-p@<redacted dns>.com"
hostname = "smtp.<redacted dns>.com"
port = 25
signature = "API Manager PROD"
enable_authentication = false

#[apim.token.revocation]
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl"
#enable_realtime_notifier = true
#realtime_notifier.ttl = 5000
#enable_persistent_notifier = true
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/"
#persistent_notifier.ttl = 5000
#persistent_notifier.username = "root"
#persistent_notifier.password = "root"

[[event_handler]]
name="userPostSelfRegistration"
subscriptions=["POST_ADD_USER"]

[service_provider]
sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"

[database.local]
url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"

[[event_listener]]
id = "token_revocation"
type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
name = "org.wso2.is.notification.ApimOauthEventInterceptor"
order = 1
[event_listener.properties]
notification_endpoint = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/internal/data/v1/notify"
username = "${admin.username}"
password = "${admin.password}"
'header.X-WSO2-KEY-MANAGER' = "default"

[identity_mgt.endpoint]
enable_self_signup_endpoint=false

我已经花了几天时间在堆栈溢出、WSO2官方文档和WSO2 github中寻找答案,但没有成功。

我是不是漏了什么东西?

EN

回答 1

Stack Overflow用户

发布于 2022-05-16 14:47:19

直到今天早上我都面临着同样的问题。https://github.com/wso2/api-manager/issues/68

我的上下文有点不同,我使用的是Docker活动的分布式部署。

我想我对deployment.toml玩得太多了,因为删除和重新创建容器解决了这个问题。

我不知道能不能帮上忙,但我补充说:

代码语言:javascript
复制
[apim.sync_runtime_artifacts.gateway]
enable = true
gateway_labels =["Default"]

[apim.sync_runtime_artifacts.publisher]
artifact_saver = "DBSaver"
publish_directly_to_gateway = true
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69945791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档