Access Error on Directus
Here is the code that causes the error:
const config = {
url: import.meta.env.PUBLIC_DIRECTUS_URL,
token: import.meta.env.DIRECTUS_STATIC_TOKEN,
contentKey: 'Content',
deleteFields: [],
collections: {
posts: {
readByQueryOption: {
fields: ['Status', 'Title', 'Slug'],
limit: -1
},
pathBuilder: (post: { Title: string }) => {
return `./content/posts/${(post.Title, { remove: /\./g })}`;
}
},
pages: {
readByQueryOption: {
fields: ['Status', 'Title', 'Slug'],
limit: -1
},
pathBuilder: (post: { Title: string }) => {
return `./content/pages/${(post.Title, { remove: /\./g })}`;
}
},
policies: {
readByQueryOption: {
fields: ['Status', 'Title', 'Slug'],
limit: -1
},
pathBuilder: (post: { Title: string }) => {
return `./content/policies/${(post.Title, { remove: /\./g })}`;
}
},
}
}
new DirectusToMarkdown(config).export();
When I launch the Astro Instance, Directus returns a 403: Forbidden response:
🚀 astro v2.7.2 started in 208ms
┃ Local http://localhost:3000/
┃ Network use --host to expose
06:34:09 PM [content] Watching src/content/ for changes
06:34:09 PM [content] Types generated
06:34:09 PM [astro] update /.astro/types.d.ts
/Users/flupsi/ecobytes/web/node_modules/.pnpm/@directus+sdk@9.14.2/node_modules/@directus/sdk/dist/sdk.cjs.js:696
throw new TransportError(err, {
^
TransportError: getaddrinfo ENOTFOUND content.ecobytes.net
at Transport.request (/Users/flupsi/ecobytes/web/node_modules/.pnpm/@directus+sdk@9.14.2/node_modules/@directus/sdk/dist/sdk.cjs.js:696:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Transport.get (/Users/flupsi/ecobytes/web/node_modules/.pnpm/@directus+sdk@9.14.2/node_modules/@directus/sdk/dist/sdk.cjs.js:710:16)
at async ItemsHandler.readByQuery (/Users/flupsi/ecobytes/web/node_modules/.pnpm/@directus+sdk@9.14.2/node_modules/@directus/sdk/dist/sdk.cjs.js:64:32)
at async DirectusToMarkdown.export (file:///Users/flupsi/ecobytes/web/node_modules/.pnpm/@resilien+directus-to-markdown@1.2.0/node_modules/@resilien/directus-to-markdown/index.js:95:22) {
parent: <ref *1> Error: getaddrinfo ENOTFOUND content.ecobytes.net
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:72:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'content.ecobytes.net',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, */*',
Authorization: 'Bearer B_llVKeHFLGG6dTp0-6QAQVxaqVk6DJU',
'User-Agent': 'axios/0.24.0'
},
baseURL: 'https://content.ecobytes.net',
withCredentials: true,
method: 'get',
url: '/items/posts',
params: { fields: [ 'Status', 'Title', 'Slug' ], limit: -1 },
data: undefined
},
request: <ref *4> Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
},
_eventsCount: 2,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'https:',
path: '/items/posts?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1',
method: 'GET',
headers: {
Accept: 'application/json, text/plain, */*',
Authorization: 'Bearer B_llVKeHFLGG6dTp0-6QAQVxaqVk6DJU',
'User-Agent': 'axios/0.24.0'
},
agent: undefined,
agents: { http: undefined, https: undefined },
auth: undefined,
hostname: 'content.ecobytes.net',
port: null,
nativeProtocols: {
'http:': {
_connectionListener: [Function: connectionListener],
METHODS: [Array],
STATUS_CODES: [Object],
Agent: [Function],
ClientRequest: [Function: ClientRequest],
IncomingMessage: [Function: IncomingMessage],
OutgoingMessage: [Function: OutgoingMessage],
Server: [Function: Server],
ServerResponse: [Function: ServerResponse],
createServer: [Function: createServer],
validateHeaderName: [Function: __node_internal_],
validateHeaderValue: [Function: __node_internal_],
get: [Function: get],
request: [Function: request],
maxHeaderSize: [Getter],
globalAgent: [Getter/Setter]
},
'https:': {
Agent: [Function: Agent],
globalAgent: [Agent],
Server: [Function: Server],
createServer: [Function: createServer],
get: [Function: get],
request: [Function: request]
}
},
pathname: '/items/posts',
search: '?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1'
},
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: <ref *2> ClientRequest {
_events: [Object: null prototype] {
response: [Function: bound onceWrapper] {
listener: [Function (anonymous)]
},
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: <ref *3> TLSSocket {
_tlsOptions: {
allowHalfOpen: undefined,
pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined,
enableTrace: undefined,
pskCallback: undefined,
highWaterMark: undefined,
onread: undefined,
signal: undefined
},
_secureEstablished: false,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: true,
_SNICallback: null,
servername: null,
alpnProtocol: null,
authorized: false,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype] {
close: [Array],
end: [Array],
newListener: [Function: keylogNewListener],
connect: [Array],
secure: [Function: onConnectSecure],
session: [Function (anonymous)],
free: [Function: onFree],
timeout: [Function: onTimeout],
agentRemove: [Function: onRemove],
error: [Function: socketErrorListener],
drain: [Function: ondrain]
},
_eventsCount: 11,
connecting: false,
_hadError: true,
_parent: null,
_host: 'content.ecobytes.net',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: [],
flowing: true,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
errorEmitted: true,
emitClose: false,
autoDestroy: true,
destroyed: true,
errored: [Circular *1],
closed: true,
closeEmitted: true,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
},
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 255,
writing: true,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: [Function: bound onFinish],
writelen: 255,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 1,
constructed: true,
prefinished: false,
errorEmitted: true,
emitClose: false,
autoDestroy: true,
errored: [Circular *1],
closed: true,
closeEmitted: true,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: false,
_sockname: null,
_pendingData: 'GET /items/posts?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1 HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Authorization: Bearer B_llVKeHFLGG6dTp0-6QAQVxaqVk6DJU\r\n' +
'User-Agent: axios/0.24.0\r\n' +
'Host: content.ecobytes.net\r\n' +
'Connection: close\r\n' +
'\r\n',
_pendingEncoding: 'latin1',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular *2],
[Symbol(res)]: TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: false,
onkeylog: [Function: onkeylog],
onhandshakestart: [Object],
onhandshakedone: [Function (anonymous)],
onocspresponse: [Function: onocspresponse],
onnewsession: [Function: onnewsessionclient],
onerror: [Function: onerror],
[Symbol(owner_symbol)]: [Circular *3]
},
[Symbol(verified)]: false,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 6231,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: {
rejectUnauthorized: true,
ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'https:',
path: null,
method: 'GET',
headers: [Object],
agent: undefined,
agents: [Object],
auth: undefined,
hostname: 'content.ecobytes.net',
port: 443,
nativeProtocols: [Object],
pathname: '/items/posts',
search: '?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1',
_defaultAgent: [Agent],
host: 'content.ecobytes.net',
servername: 'content.ecobytes.net',
_agentKey: 'content.ecobytes.net:443:::::::::::::::::::::',
encoding: null,
singleUse: true
}
},
_header: 'GET /items/posts?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1 HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Authorization: Bearer B_llVKeHFLGG6dTp0-6QAQVxaqVk6DJU\r\n' +
'User-Agent: axios/0.24.0\r\n' +
'Host: content.ecobytes.net\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype] {
free: [Function (anonymous)],
newListener: [Function: maybeEnableKeylog]
},
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype] { path: null },
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {
'content.ecobytes.net:443:::::::::::::::::::::': [Array]
},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
maxCachedSessions: 100,
_sessionCache: { map: {}, list: [] },
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/items/posts?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'content.ecobytes.net',
protocol: 'https:',
_redirectable: [Circular *4],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [ 'Accept', 'application/json, text/plain, */*' ],
authorization: [
'Authorization',
'Bearer B_llVKeHFLGG6dTp0-6QAQVxaqVk6DJU'
],
'user-agent': [ 'User-Agent', 'axios/0.24.0' ],
host: [ 'Host', 'content.ecobytes.net' ]
}
},
_currentUrl: 'https://content.ecobytes.net/items/posts?fields[]=Status&fields[]=Title&fields[]=Slug&limit=-1',
[Symbol(kCapture)]: false
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
},
response: undefined,
errors: []
}
Edited by Flupsi